netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ken-ichirou MATSUZAWA <chamaken@gmail.com>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH lnf-ct 2/2] qa: add tests for new bitmask functions
Date: Wed, 10 Sep 2014 17:53:31 +0900	[thread overview]
Message-ID: <20140910085331.GC23549@gmail.com> (raw)
In-Reply-To: <20140910084525.GA23549@gmail.com>

for nfct_bitmask_clear() and nfct_bitmask_equal()

Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
---
 qa/test_api.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/qa/test_api.c b/qa/test_api.c
index f17db31..fe1cb78 100644
--- a/qa/test_api.c
+++ b/qa/test_api.c
@@ -80,6 +80,43 @@ static void test_nfct_bitmask(void)
 		assert(!nfct_bitmask_test_bit(b, i));
 	}
 
+	/* nfct_bitmask_clear() */
+	for (i = 0; i < maxb; i++) {
+		nfct_bitmask_set_bit(b, i);
+		assert(nfct_bitmask_test_bit(b, i));
+		nfct_bitmask_clear(b);
+		assert(!nfct_bitmask_test_bit(b, i));
+	}
+
+	for (i = 0; i < maxb; i++)
+		nfct_bitmask_set_bit(b, i);
+	nfct_bitmask_clear(b);
+	for (i = 0; i < maxb; i++)
+		assert(!nfct_bitmask_test_bit(b, i));
+
+	/* nfct_bitmask_equal() */
+	for (i = 0; i < maxb / 32 * 32; i += 32) {
+		a = nfct_bitmask_new(i);
+		assert(!nfct_bitmask_equal(a, b));
+		nfct_bitmask_destroy(a);
+	}
+
+	a = nfct_bitmask_clone(b);
+	assert(nfct_bitmask_equal(a, b));
+	for (i = 0; i < maxb; i++) {
+		if (nfct_bitmask_test_bit(a, i)) {
+			nfct_bitmask_unset_bit(a, i);
+			assert(!nfct_bitmask_equal(a, b));
+			nfct_bitmask_set_bit(a, i);
+		} else {
+			nfct_bitmask_set_bit(a, i);
+			assert(!nfct_bitmask_equal(a, b));
+			nfct_bitmask_unset_bit(a, i);
+		}
+		assert(nfct_bitmask_equal(a, b));
+	}
+
+	nfct_bitmask_destroy(a);
 	nfct_bitmask_destroy(b);
 
 	ct1 = nfct_new();
-- 
2.1.0

  parent reply	other threads:[~2014-09-10  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  8:45 [PATCH lnf-ct 0/2] add new bitmask functions Ken-ichirou MATSUZAWA
2014-09-10  8:48 ` [PATCH lnf-ct 1/2] add two " Ken-ichirou MATSUZAWA
2014-09-10  8:53   ` Florian Westphal
2014-09-11 19:38   ` Florian Westphal
2014-09-10  8:53 ` Ken-ichirou MATSUZAWA [this message]
2014-09-11 19:39   ` [PATCH lnf-ct 2/2] qa: add tests for " Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140910085331.GC23549@gmail.com \
    --to=chamaken@gmail.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).