forked from arminbiere/satch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testapi.c
75 lines (73 loc) · 2.05 KB
/
testapi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "satch.h"
#include <stdio.h>
#include <stdlib.h>
#undef NDEBUG
#include <assert.h>
int
main (void)
{
{
struct satch *solver = satch_init ();
int res = satch_solve (solver, -1);
assert (res == 10);
satch_release (solver);
}
{
struct satch *solver = satch_init ();
satch_add (solver, 0);
int res = satch_solve (solver, -1);
assert (res == 20);
satch_release (solver);
}
{
struct satch *solver = satch_init ();
satch_add (solver, 1);
satch_add (solver, 0);
int res = satch_solve (solver, -1);
assert (res == 10);
int value = satch_val (solver, 1);
assert (value == 1);
satch_release (solver);
}
{
struct satch *solver = satch_init ();
satch_add (solver, 1), satch_add (solver, 2), satch_add (solver, 0);
satch_add (solver, 1), satch_add (solver, -2), satch_add (solver, 0);
satch_add (solver, -1), satch_add (solver, 2), satch_add (solver, 0);
int res = satch_solve (solver, -1);
assert (res == 10);
for (int i = 0; i < 3; i++)
{
int tmp = satch_val (solver, 1);
assert (tmp == 1);
tmp = satch_val (solver, 2);
assert (tmp == 2);
}
satch_release (solver);
}
{
struct satch *solver = satch_init ();
satch_add (solver, -1), satch_add (solver, -2), satch_add (solver, 0);
satch_add (solver, -1), satch_add (solver, 2), satch_add (solver, 0);
satch_add (solver, 1), satch_add (solver, -2), satch_add (solver, 0);
satch_add (solver, 1), satch_add (solver, 2), satch_add (solver, 0);
int res = satch_solve (solver, -1);
assert (res == 20);
satch_release (solver);
}
{
struct satch *solver = satch_init ();
for (int r = -1; r <= 1; r += 2)
for (int s = -1; s <= 1; s += 2)
for (int t = -1; t <= 1; t += 2)
satch_add (solver, r * 1), satch_add (solver, s * 2),
satch_add (solver, t * 3), satch_add (solver, 0);
satch_set_verbose_level (solver, 1);
int limit = 0, res;
while (!(res = satch_solve (solver, limit++)))
;
assert (res == 20);
satch_release (solver);
}
return 0;
}