1
+ /* kitty: C++ truth table library
2
+ * Copyright (C) 2017-2018 EPFL
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person
5
+ * obtaining a copy of this software and associated documentation
6
+ * files (the "Software"), to deal in the Software without
7
+ * restriction, including without limitation the rights to use,
8
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the
10
+ * Software is furnished to do so, subject to the following
11
+ * conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
+ * OTHER DEALINGS IN THE SOFTWARE.
24
+ */
25
+
26
+ #include < gtest/gtest.h>
27
+
28
+ #include < kitty/constructors.hpp>
29
+ #include < kitty/cnf.hpp>
30
+ #include < kitty/dynamic_truth_table.hpp>
31
+ #include < kitty/static_truth_table.hpp>
32
+
33
+ #include " utility.hpp"
34
+
35
+ using namespace kitty ;
36
+
37
+ class CNFTest : public kitty ::testing::Test
38
+ {
39
+ };
40
+
41
+ TEST_F ( CNFTest, small_cnf_dynamic )
42
+ {
43
+ auto f = from_hex ( 3 , " c2" );
44
+ const auto cubes = cnf_characteristic ( f );
45
+
46
+ dynamic_truth_table char1 ( f.num_vars () + 1 ), char2 ( f.num_vars () + 1 );
47
+ create_from_clauses ( char1, cubes );
48
+ create_characteristic ( char2, f );
49
+ EXPECT_EQ ( char1, char2 );
50
+ }
51
+
52
+ TEST_F ( CNFTest, random_cnf_dynamic )
53
+ {
54
+ dynamic_truth_table f ( 10u ), f_c1 ( 11u ), f_c2 ( 11u );
55
+ for ( auto i = 0 ; i < 50 ; ++i )
56
+ {
57
+ create_random ( f );
58
+ create_from_clauses ( f_c1, cnf_characteristic ( f ) );
59
+ create_characteristic ( f_c2, f );
60
+ EXPECT_EQ ( f_c1, f_c2 );
61
+ }
62
+ }
63
+
64
+ TEST_F ( CNFTest, random_cnf_static )
65
+ {
66
+ static_truth_table<10 > f;
67
+ static_truth_table<11 > f_c1, f_c2;
68
+ for ( auto i = 0 ; i < 50 ; ++i )
69
+ {
70
+ create_random ( f );
71
+ create_from_clauses ( f_c1, cnf_characteristic ( f ) );
72
+ create_characteristic ( f_c2, f );
73
+ EXPECT_EQ ( f_c1, f_c2 );
74
+ }
75
+ }
0 commit comments