Hash :
1792fa78
Author :
Thomas de Grivel
Date :
2024-08-10T15:32:54
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
/* kc3
* Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <string.h>
#include "../libkc3/fact.h"
#include "../libkc3/str.h"
#include "fact_test.h"
#include "test.h"
void fact_test (void);
TEST_CASE_PROTOTYPE(fact_init);
void fact_test (void)
{
TEST_CASE_RUN(fact_init);
}
void fact_test_clean_1 (s_fact *fact)
{
assert(fact);
tag_delete((s_tag *) fact->subject);
}
void fact_test_clean_3 (s_fact *fact)
{
assert(fact);
tag_delete((s_tag *) fact->subject);
tag_delete((s_tag *) fact->predicate);
tag_delete((s_tag *) fact->object);
}
s_fact * fact_test_init_1 (s_fact *fact, const char *tag)
{
assert(fact);
fact->subject = fact->predicate = fact->object = tag_new_1(tag);
return fact;
}
s_fact * fact_test_init_3 (s_fact *fact, const char *subject,
const char *predicate, const char *object)
{
assert(fact);
fact->subject = tag_new_1(subject);
fact->predicate = tag_new_1(predicate);
fact->object = tag_new_1(object);
return fact;
}
TEST_CASE(fact_init)
{
s_tag sym[3];
s_fact fact;
tag_init_sym(sym, sym_1("A"));
tag_init_sym(sym + 1, sym_1("B"));
tag_init_sym(sym + 2, sym_1("C"));
TEST_EQ(fact_init(&fact, sym, sym + 1, sym + 2), &fact);
TEST_EQ(fact.subject, sym);
TEST_EQ(fact.predicate, sym + 1);
TEST_EQ(fact.object, sym + 2);
}
TEST_CASE_END(fact_init)