Revision: 51616
          http://brlcad.svn.sourceforge.net/brlcad/?rev=51616&view=rev
Author:   starseeker
Date:     2012-07-20 02:33:03 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
Add bu_bitv_and tests

Modified Paths:
--------------
    brlcad/trunk/src/libbu/tests/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/src/libbu/tests/bu_bitv_and.c

Modified: brlcad/trunk/src/libbu/tests/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libbu/tests/CMakeLists.txt 2012-07-20 02:21:10 UTC (rev 
51615)
+++ brlcad/trunk/src/libbu/tests/CMakeLists.txt 2012-07-20 02:33:03 UTC (rev 
51616)
@@ -1,4 +1,5 @@
 BRLCAD_ADDEXEC(tester_bu_basename bu_basename.c libbu NO_INSTALL LOCAL)
+BRLCAD_ADDEXEC(tester_bu_bitv_and bu_bitv_and.c libbu NO_INSTALL LOCAL)
 BRLCAD_ADDEXEC(tester_bu_hex_to_bitv bu_hex_to_bitv.c libbu NO_INSTALL LOCAL)
 BRLCAD_ADDEXEC(tester_bu_bitv bu_bitv.c libbu NO_INSTALL LOCAL)
 BRLCAD_ADDEXEC(tester_bu_booleanize bu_booleanize.c libbu NO_INSTALL LOCAL)
@@ -36,6 +37,12 @@
 add_test(bu_basename_p__p__p_                               tester_bu_basename 
"...")
 add_test(bu_basename_sp__sp__sp_                            tester_bu_basename 
"   ")
 
+###############################
+#      bu_bitv_and testing    #
+###############################
+add_test(bu_bitv_and_test1                                  tester_bu_bitv_and 
"ffffffff" "00000000" "00000000")
+add_test(bu_bitv_and_test2                                  tester_bu_bitv_and 
"ab00" "1200" "0200")
+
 ##################################
 #      bu_hex_to_bitv testing    #
 ##################################

Added: brlcad/trunk/src/libbu/tests/bu_bitv_and.c
===================================================================
--- brlcad/trunk/src/libbu/tests/bu_bitv_and.c                          (rev 0)
+++ brlcad/trunk/src/libbu/tests/bu_bitv_and.c  2012-07-20 02:33:03 UTC (rev 
51616)
@@ -0,0 +1,86 @@
+/*                 B U _ B I T V _ A N D . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2012 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+
+#include "common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "bu.h"
+
+int
+test_bu_bitv_and(char *inp1 , char *inp2 , char *exp)
+{
+    struct bu_bitv *res_bitv , *res_bitv1 , *result;
+    struct bu_vls *a , *b;
+    int pass;
+
+    a = bu_vls_vlsinit();
+    b = bu_vls_vlsinit();
+
+    res_bitv1 = bu_hex_to_bitv(inp1);
+    res_bitv  = bu_hex_to_bitv(inp2);
+    result    = bu_hex_to_bitv(exp);
+
+    bu_bitv_and(res_bitv1,res_bitv);
+    bu_bitv_vls(a,res_bitv1);
+    bu_bitv_vls(b,result);
+
+    if (!bu_strcmp(a->vls_str , b->vls_str)) {
+       printf("\nbu_bitv_and test PASSED Input1:%s Input2:%s Output:%s", inp1, 
inp2, exp);
+       pass = 1;
+    } else {
+       printf("\nbu_bitv_and test FAILED Input1:%s Input2:%s Expected:%s", 
inp1, inp2, exp);
+       pass = 0;
+    }
+
+    bu_bitv_free(res_bitv);
+    bu_bitv_free(res_bitv1);
+    bu_bitv_free(result);
+
+    return pass;
+}
+
+
+int
+main(int argc , char *argv[])
+{
+    int ret;
+
+    if(argc < 4)
+      return -1;
+
+    ret = test_bu_bitv_and(argv[1], argv[2], argv[3]);
+    return !ret;
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libbu/tests/bu_bitv_and.c
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to