-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.pl
74 lines (66 loc) · 1.99 KB
/
test.pl
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
:- use_module(fd).
:- use_module(library(plunit)).
:- begin_tests(fd).
% normal forms
test(nf01) :- nf(abc, [a->b], nf1NF).
test(nf02) :- nf(lmno, [m->o, lm->ln, n->m, no->m], nf1NF).
test(nf03) :- nf(abcd, [c->b, b->d, ab->ac, cd->b], nf1NF).
test(nf04) :- nf(abcd, [ab->c, c->d], nf2NF).
test(nf05) :- nf(vui, [vu->i, i->v], nf3NF).
test(nf06) :- nf(abcdef, [a->b, b->c, c->a, d->e, e->f, f->d], nf3NF).
test(nf07) :- nf(abc, [a->b, b->c, c->a], nfBCNF).
test(nf08) :- nf(abcdef, [a->d, b->e, c->f, d->b, e->c, f->a], nfBCNF).
% keys
test(keys01) :- keys(abcdef, [a->b, b->c, c->a, d->e, e->f, f->d], [af, ae, ad, bf, be, bd, cf, ce, cd]).
% primary attributes
test(primaryattributes01) :- primaryattributes(abcd, [a->b, bc->ad], [a, b, c]).
test(primaryattributes02) :- primaryattributes(abcd, [], [a, b, c, d]).
% secondary attributes
test(secondaryattributes01) :- secondaryattributes(abcd, [a->b, bc->ad], [d]).
test(secondaryattributes02) :- secondaryattributes(abcd, [], []).
% fmin
test(fmin01) :-
fmins_all(
[a->b, ab->d, b->a, d->a],
[[ (a->b), (b->d), (d->a)], [ (a->b), (a->d), (b->a), (d->a)]]
).
test(fmin02) :-
fmins_all(
[cd->e, ab->cd, d->a, a->b, b->ac],
[[ (a->b), (b->c), (b->d), (d->a), (d->e)],
[ (a->b), (a->d), (b->a), (b->c), (d->a), (d->e)],
[ (a->b), (a->c), (b->d), (d->a), (d->e)],
[ (a->b), (a->c), (a->d), (b->a), (d->a), (d->e)]]
).
test(fmin03) :- fmins_all(
[abcd->e, e->d, a->b, ac->d],
[[(a->b), (ac->e), (e->d)]]
).
% d3nf
test(d3nf01) :-
d3nfs_all(
abcde,
[ab->b, b->c, c->bd],
[[ace, bc, cd],
[abe, bc, cd]]
).
% bcnf
test(bcnf01) :-
bcnfs_all(
abcde,
[ab->b, b->c, c->bd],
[[ab, abe, bc, bd],
[abe, bc, bd],
[abe, bc, bd, be],
[ac, ace, bc, cd],
[ace, bc, cd],
[ace, bc, cd, ce],
[ab, ace, bc, cd],
[ab, abe, bc, cd],
[abe, ac, bc, cd],
[abe, bc, cd],
[abe, bc, be, cd],
[abe, bc, cd, ce],
[ace, bc, be, cd]]
).
:- end_tests(lists).