diff --git a/libc3/bool.c b/libc3/bool.c
index 1cf528b..e17a7dc 100644
--- a/libc3/bool.c
+++ b/libc3/bool.c
@@ -15,15 +15,6 @@
#include "buf.h"
#include "buf_inspect.h"
-s8 bool_compare (e_bool a, e_bool b)
-{
- if (! a && b)
- return -1;
- if ((! a && ! b) || (a && b))
- return 0;
- return 1;
-}
-
s_str * bool_inspect (e_bool x, s_str *dest)
{
sw size;
diff --git a/libc3/c3.h b/libc3/c3.h
index 0ec6bfe..380d574 100644
--- a/libc3/c3.h
+++ b/libc3/c3.h
@@ -34,7 +34,6 @@
#include "ident.h"
#include "integer.h"
#include "list.h"
-#include "ptr.h"
#include "quote.h"
#include "str.h"
#include "tag.h"
diff --git a/libc3/character.c b/libc3/character.c
index 5644889..55584ca 100644
--- a/libc3/character.c
+++ b/libc3/character.c
@@ -26,15 +26,6 @@ character character_1 (const s8 *p)
return c;
}
-s8 character_compare (character a, character b)
-{
- if (a < b)
- return -1;
- if (a == b)
- return 0;
- return 1;
-}
-
e_bool character_is_digit (character c)
{
return ('0' <= c && c <= '9');
diff --git a/libc3/compare.c b/libc3/compare.c
index 88cfa54..ec3e150 100644
--- a/libc3/compare.c
+++ b/libc3/compare.c
@@ -28,6 +28,15 @@
return 0; \
} \
+s8 compare_bool (e_bool a, e_bool b)
+{
+ if (! a && b)
+ return -1;
+ if ((! a && ! b) || (a && b))
+ return 0;
+ return 1;
+}
+
s8 compare_call (const s_call *a, const s_call *b)
{
s8 r;
@@ -42,6 +51,7 @@ s8 compare_call (const s_call *a, const s_call *b)
return compare_list(a->arguments, b->arguments);
}
+COMPARE_DEF(character)
COMPARE_DEF(f32)
@@ -64,7 +74,7 @@ s8 compare_fact (const s_fact *a, const s_fact *b)
return r;
}
-s8 fact_compare_unbound_var_count (const s_fact *a,
+s8 compare_fact_unbound_var_count (const s_fact *a,
const s_fact *b)
{
u8 a_count;
@@ -126,6 +136,20 @@ s8 compare_fact_osp (const s_fact *a, const s_fact *b)
return r;
}
+s8 compare_ident (const s_ident *a, const s_ident *b)
+{
+ sw r;
+ if (a == b)
+ return 0;
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+ if ((r = compare_sym(a->module, b->module)))
+ return r;
+ return compare_sym(a->sym, b->sym);
+}
+
s8 compare_integer (const s_integer *a, const s_integer *b)
{
sw r;
@@ -189,6 +213,15 @@ s8 compare_list (const s_list *a, const s_list *b)
}
}
+s8 compare_ptag (const p_tag a, const p_tag b)
+{
+ if (a < b)
+ return -1;
+ if (a == b)
+ return 0;
+ return 1;
+}
+
s8 compare_ptr (const void *a, const void *b)
{
if (a < b)
diff --git a/libc3/compare.h b/libc3/compare.h
index 233e06f..07774dd 100644
--- a/libc3/compare.h
+++ b/libc3/compare.h
@@ -41,6 +41,7 @@ COMPARE_PROTOTYPE(s16);
COMPARE_PROTOTYPE(s32);
COMPARE_PROTOTYPE(s64);
s8 compare_str (const s_str *a, const s_str *b);
+s8 compare_sym (const s_sym *a, const s_sym *b);
s8 compare_tag (const s_tag *a, const s_tag *b);
s8 compare_tuple (const s_tuple *a, const s_tuple *b);
COMPARE_PROTOTYPE(u8);
diff --git a/libc3/facts.c b/libc3/facts.c
index 5a47243..193b797 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -24,6 +24,7 @@
#include "facts.h"
#include "facts_cursor.h"
#include "facts_with.h"
+#include "hash.h"
#include "set__fact.h"
#include "set__tag.h"
#include "skiplist__fact.h"
@@ -82,6 +83,7 @@ sw facts_dump (const s_facts *facts, s_buf *buf)
{
s_facts_cursor cursor;
s_fact *fact;
+ t_hash hash;
s_tag predicate;
s_tag object;
sw r;
@@ -104,23 +106,26 @@ sw facts_dump (const s_facts *facts, s_buf *buf)
if ((r = buf_write_1(buf, "}\n")) < 0)
return r;
result += r;
+ hash_init(&hash);
facts_with_0(facts, &cursor, &subject, &predicate, &object);
while ((fact = facts_cursor_next(&cursor))) {
- if ((r = facts_log_add(buf, fact)) < 0)
+ hash_update_fact(&hash, fact);
+ if ((r = buf_inspect_fact(buf, fact)) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1(buf, "\n")) < 0)
return r;
result += r;
}
- /*
- if ((r = buf_write_1(buf, "\n%{hash: 0x")) < 0)
+ if ((r = buf_write_1(buf, "%{hash: 0x")) < 0)
return r;
result += r;
- if ((r = buf_inspect_u64_hex(buf, hash_u64)) < 0)
+ if ((r = buf_inspect_u64_hex(buf, hash_to_u64(&hash))) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, "}\n")) < 0)
return r;
result += r;
- */
return result;
}
@@ -197,7 +202,7 @@ sw facts_load (s_facts *facts, s_buf *buf)
assert(facts);
assert(buf);
if ((r = buf_read_1(buf,
- "%{module: C3.Facts,\n"
+ "%{module: C3.Facts.Dump,\n"
" version: 0x0000000000000001,\n"
" count: 0x")) < 0)
return r;
@@ -208,26 +213,16 @@ sw facts_load (s_facts *facts, s_buf *buf)
return r;
result += r;
for (i = 0; i < count; i++) {
- if ((r = buf_read_1(buf, "add ")) < 0)
- break;
- result += r;
- if (r) {
- if ((r = buf_parse_fact(buf, &fact)) <= 0)
- break;
- result += r;
- facts_add_fact(facts, &fact);
- goto ok;
- }
- if ((r = buf_read_1(buf, "remove ")) <= 0)
- break;
- result += r;
if ((r = buf_parse_fact(buf, &fact)) <= 0)
break;
result += r;
- facts_remove_fact(facts, &fact);
- ok:
+ facts_add_fact(facts, &fact);
buf_read_1(buf, "\n");
}
+ /*
+ buf_write_1(buf, "%{hash: 0x");
+ buf_inspect_u64_hex(buf, hash_u64);
+ */
return result;
}
@@ -349,6 +344,37 @@ sw facts_open_file (s_facts *facts, const s8 *path)
return r;
}
+sw facts_open_log (s_facts *facts, s_buf *buf)
+{
+ s_fact fact;
+ sw r;
+ sw result = 0;
+ assert(facts);
+ assert(buf);
+ while (1) {
+ if ((r = buf_read_1(buf, "add ")) < 0)
+ break;
+ result += r;
+ if (r) {
+ if ((r = buf_parse_fact(buf, &fact)) <= 0)
+ break;
+ result += r;
+ facts_add_fact(facts, &fact);
+ goto ok;
+ }
+ if ((r = buf_read_1(buf, "remove ")) <= 0)
+ break;
+ result += r;
+ if ((r = buf_parse_fact(buf, &fact)) <= 0)
+ break;
+ result += r;
+ facts_remove_fact(facts, &fact);
+ ok:
+ buf_read_1(buf, "\n");
+ }
+ return result;
+}
+
s_tag * facts_ref_tag (s_facts *facts, const s_tag *tag)
{
s_set_item__tag *item;
@@ -403,6 +429,7 @@ sw facts_save_file (s_facts *facts, const s8 *path)
if ((r = facts_dump(facts, buf)) < 0)
goto ko;
result += r;
+ buf_flush(buf);
facts->log = buf;
return result;
ko:
diff --git a/libc3/hash.c b/libc3/hash.c
index 697cd61..a8f9b11 100644
--- a/libc3/hash.c
+++ b/libc3/hash.c
@@ -69,6 +69,10 @@ void hash_update_call (t_hash *hash, const s_call *call)
HASH_UPDATE_DEF(character)
+HASH_UPDATE_DEF(f32)
+
+HASH_UPDATE_DEF(f64)
+
void hash_update_fact (t_hash *hash, const s_fact *fact)
{
const u8 type = 3;
@@ -119,6 +123,13 @@ void hash_update_list (t_hash *hash, const s_list *list)
}
}
+void hash_update_ptag (t_hash *hash, const p_tag ptag)
+{
+ const s8 type[] = "ptag";
+ hash_update(hash, type, strlen(type));
+ hash_update(hash, &ptag, sizeof(ptag));
+}
+
void hash_update_quote (t_hash *hash, const p_quote x)
{
const s8 type[] = "quote";
@@ -127,8 +138,11 @@ void hash_update_quote (t_hash *hash, const p_quote x)
}
HASH_UPDATE_DEF(s8)
+
HASH_UPDATE_DEF(s16)
+
HASH_UPDATE_DEF(s32)
+
HASH_UPDATE_DEF(s64)
void hash_update_str (t_hash *hash, const s_str *str)
diff --git a/libc3/ident.c b/libc3/ident.c
index 62966e6..6936d73 100644
--- a/libc3/ident.c
+++ b/libc3/ident.c
@@ -32,20 +32,6 @@ e_bool ident_character_is_reserved (character c)
c == '}');
}
-s8 ident_compare (const s_ident *a, const s_ident *b)
-{
- sw r;
- if (a == b)
- return 0;
- if (!a)
- return -1;
- if (!b)
- return 1;
- if ((r = sym_compare(a->module, b->module)))
- return r;
- return sym_compare(a->sym, b->sym);
-}
-
s_ident * ident_copy (const s_ident *src, s_ident *dest)
{
dest->module = src->module;
diff --git a/libc3/ptr.c b/libc3/ptr.c
deleted file mode 100644
index 167606c..0000000
--- a/libc3/ptr.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers 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 "ptr.h"
-
-s8 ptr_compare (const void *a, const void *b)
-{
- if (a < b)
- return -1;
- if (a == b)
- return 0;
- return 1;
-}
diff --git a/libc3/ptr.h b/libc3/ptr.h
deleted file mode 100644
index 5e0a535..0000000
--- a/libc3/ptr.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* c3
- * Copyright 2022 kmx.io <contact@kmx.io>
- *
- * Permission is hereby granted to use this software excepted
- * on Apple computers 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.
- */
-#ifndef PTR_H
-#define PTR_H
-
-#include "hash.h"
-#include "types.h"
-
-s8 ptr_compare (const void *a, const void *b);
-
-#endif /* PTR_H */
diff --git a/libc3/sources.mk b/libc3/sources.mk
index 6de8184..05b21cd 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -1,3 +1,3 @@
# sources.mk generated by update_sources
-SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c
-LO_SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c
+SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c
+LO_SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c
diff --git a/libc3/sources.sh b/libc3/sources.sh
index fb8d1ad..d8e0645 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,3 +1,3 @@
# sources.sh generated by update_sources
-SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
-LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c ptr.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
+SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
+LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/libc3/sym.h b/libc3/sym.h
index ebb389c..a3a0466 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -34,8 +34,6 @@ const s_sym * sym_1 (const s8 *p);
e_bool sym_character_is_reserved (character c);
-s8 sym_compare (const s_sym *a, const s_sym *b);
-
/** @brief Call when exiting program. */
void sym_delete_all ();
diff --git a/test/bool_test.c b/test/bool_test.c
index f91e51d..ff7be1d 100644
--- a/test/bool_test.c
+++ b/test/bool_test.c
@@ -28,25 +28,15 @@
} while (0)
void bool_test ();
-void bool_test_compare ();
void bool_test_compat ();
void bool_test_inspect ();
void bool_test ()
{
- bool_test_compare();
bool_test_compat();
bool_test_inspect();
}
-void bool_test_compare ()
-{
- TEST_EQ(bool_compare(false, false), 0);
- TEST_EQ(bool_compare(false, true), -1);
- TEST_EQ(bool_compare(true, false), 1);
- TEST_EQ(bool_compare(true, true), 0);
-}
-
void bool_test_compat ()
{
TEST_EQ(true, 1);
diff --git a/test/character_test.c b/test/character_test.c
index 85ca58e..2a0e199 100644
--- a/test/character_test.c
+++ b/test/character_test.c
@@ -17,7 +17,6 @@
#include "test.h"
void character_test_1 ();
-void character_test_compare ();
void character_test_is_digit ();
void character_test_is_lowercase ();
void character_test_is_space ();
@@ -28,7 +27,6 @@ void character_test_utf8_size ();
void character_test ()
{
character_test_1();
- character_test_compare();
character_test_is_digit();
character_test_is_lowercase();
character_test_is_space();
@@ -76,21 +74,6 @@ void character_test_1 ()
TEST_EQ(character_1("ꝝ"), 42845);
}
-void character_test_compare ()
-{
- TEST_EQ(character_compare('0', '0'), 0);
- TEST_EQ(character_compare('0', '1'), -1);
- TEST_EQ(character_compare('1', '0'), 1);
- TEST_EQ(character_compare('1', '1'), 0);
- TEST_EQ(character_compare('0', 'A'), -1);
- TEST_EQ(character_compare('A', '0'), 1);
- TEST_EQ(character_compare('A', 'A'), 0);
- TEST_EQ(character_compare('A', 'B'), -1);
- TEST_EQ(character_compare('B', 'A'), 1);
- TEST_EQ(character_compare('A', 'a'), -1);
- TEST_EQ(character_compare('a', 'A'), 1);
-}
-
void character_test_is_digit ()
{
character c;
diff --git a/test/compare_test.c b/test/compare_test.c
index d550d44..7158c1d 100644
--- a/test/compare_test.c
+++ b/test/compare_test.c
@@ -11,22 +11,75 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
-#include "test.h"
-#include "../libc3/compare.h"
+#include "compare_test.h"
+#include "../libc3/list.h"
#include "../libc3/tag.h"
+#include "../libc3/tuple.h"
+
+#define COMPARE_TEST_LIST(a, b, expected) \
+ do { \
+ s_list *tmp_a = (a); \
+ s_list *tmp_b = (b); \
+ test_context("compare_list(" # a ", " # b ") -> " # expected); \
+ TEST_EQ(compare_list(tmp_a, tmp_b), (expected)); \
+ list_delete(tmp_a); \
+ list_delete(tmp_b); \
+ } while (0)
#define COMPARE_TEST_TAG(a, b, expected) \
do { \
TEST_EQ(compare_tag((a), (b)), (expected)); \
} while (0)
+#define COMPARE_TEST_TUPLE(a, b, expected) \
+ do { \
+ test_context("compare_tuple(" # a ", " # b ") -> " # expected); \
+ TEST_EQ(compare_tuple((a), (b)), (expected)); \
+ test_context(NULL); \
+ } while (0)
+
+void compare_test_bool ();
+void compare_test_character ();
void compare_test_f32 ();
void compare_test_f64 ();
+void compare_test_list ();
+void compare_test_str ();
+void compare_test_tag ();
+void compare_test_tuple ();
void compare_test ()
{
+ compare_test_bool();
+ compare_test_character();
compare_test_f32();
compare_test_f64();
+ compare_test_list();
+ compare_test_str();
+ compare_test_tag();
+ compare_test_tuple();
+}
+
+void compare_test_bool ()
+{
+ TEST_EQ(compare_bool(false, false), 0);
+ TEST_EQ(compare_bool(false, true), -1);
+ TEST_EQ(compare_bool(true, false), 1);
+ TEST_EQ(compare_bool(true, true), 0);
+}
+
+void compare_test_character ()
+{
+ TEST_EQ(compare_character('0', '0'), 0);
+ TEST_EQ(compare_character('0', '1'), -1);
+ TEST_EQ(compare_character('1', '0'), 1);
+ TEST_EQ(compare_character('1', '1'), 0);
+ TEST_EQ(compare_character('0', 'A'), -1);
+ TEST_EQ(compare_character('A', '0'), 1);
+ TEST_EQ(compare_character('A', 'A'), 0);
+ TEST_EQ(compare_character('A', 'B'), -1);
+ TEST_EQ(compare_character('B', 'A'), 1);
+ TEST_EQ(compare_character('A', 'a'), -1);
+ TEST_EQ(compare_character('a', 'A'), 1);
}
void compare_test_f32 ()
@@ -80,6 +133,40 @@ void compare_test_f64 ()
1);
}
+void compare_test_list ()
+{
+ COMPARE_TEST_LIST(NULL, NULL, 0);
+ COMPARE_TEST_LIST(list_1("[A, B]"), list_1("[A, C]"), -1);
+ COMPARE_TEST_LIST(list_1("[A, C]"), list_1("[A, B]"), 1);
+}
+
+void compare_test_str ()
+{
+ s_str *a;
+ TEST_EQ((a = str_new_empty(), compare_str(a, a)), 0);
+ str_delete(a);
+ TEST_EQ((a = str_new_1(NULL, "abc"), compare_str(a, a)), 0);
+ str_delete(a);
+ COMPARE_TEST_STR(str_new_empty(), str_new_empty(), 0);
+ COMPARE_TEST_STR(str_new_empty(), str_new_1(NULL, "0"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "0"), str_new_empty(), 1);
+ COMPARE_TEST_STR(str_new_1(NULL, "0"), str_new_1(NULL, "0"), 0);
+ COMPARE_TEST_STR(str_new_1(NULL, "0"), str_new_1(NULL, "A"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "0"), 1);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "01"), 0);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "012"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "02"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "023"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "01"), str_new_1(NULL, "ABC"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "0"), 1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "01"), 1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "012"), 0);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "0123"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "013"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "0134"), -1);
+ COMPARE_TEST_STR(str_new_1(NULL, "012"), str_new_1(NULL, "ABC"), -1);
+}
+
void compare_test_tag ()
{
s_tag a;
@@ -270,3 +357,30 @@ void compare_test_tag ()
tag_clean(&a);
tag_clean(&b);
}
+
+void compare_test_tuple ()
+{
+ s_tuple a;
+ s_tuple b;
+ COMPARE_TEST_TUPLE(tuple_init_1(&a, "{A, B}"),
+ tuple_init_1(&b, "{A, B}"), 0);
+ COMPARE_TEST_TUPLE(&a, &a, 0);
+ tuple_clean(&a);
+ tuple_clean(&b);
+ COMPARE_TEST_TUPLE(tuple_init_1(&a, "{A, A}"),
+ tuple_init_1(&b, "{A, B}"), -1);
+ tuple_clean(&a);
+ tuple_clean(&b);
+ COMPARE_TEST_TUPLE(tuple_init_1(&a, "{A, B}"),
+ tuple_init_1(&b, "{A, A}"), 1);
+ tuple_clean(&a);
+ tuple_clean(&b);
+ COMPARE_TEST_TUPLE(tuple_init_1(&a, "{A, B}"),
+ tuple_init_1(&b, "{A, B, C}"), -1);
+ tuple_clean(&a);
+ tuple_clean(&b);
+ COMPARE_TEST_TUPLE(tuple_init_1(&a, "{A, B, C}"),
+ tuple_init_1(&b, "{A, B}"), 1);
+ tuple_clean(&a);
+ tuple_clean(&b);
+}
diff --git a/test/compare_test.h b/test/compare_test.h
new file mode 100644
index 0000000..3f68416
--- /dev/null
+++ b/test/compare_test.h
@@ -0,0 +1,41 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software excepted
+ * on Apple computers 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.
+ */
+#ifndef COMPARE_TEST_H
+#define COMPARE_TEST_H
+
+#include "test.h"
+#include "../libc3/compare.h"
+#include "../libc3/str.h"
+
+#define COMPARE_TEST_STR(a, b, expected) \
+ do { \
+ const s_str *a_ = (a); \
+ const s_str *b_ = (b); \
+ sw tmp = compare_str(a_, b_); \
+ if (tmp == expected) { \
+ test_ok(); \
+ } \
+ else { \
+ test_ko(); \
+ printf("\n%sAssertion failed in %s:%d %s\n" \
+ "compare_str(%s, %s) == %s\n" \
+ "Expected %s got %ld.%s\n", \
+ TEST_COLOR_KO, \
+ __FILE__, __LINE__, __func__, \
+ # a, # b, # expected, # expected, tmp, \
+ TEST_COLOR_RESET); \
+ } \
+ } while (0)
+
+#endif /* COMPARE_TEST_H */
diff --git a/test/fact_test.h b/test/fact_test.h
index efa7ee0..92cfe5a 100644
--- a/test/fact_test.h
+++ b/test/fact_test.h
@@ -22,7 +22,7 @@
s_fact *fact_test; \
fact_expected = (expected); \
fact_test = (test); \
- if (fact_compare(fact_test, fact_expected) == 0) { \
+ if (compare_fact(fact_test, fact_expected) == 0) { \
test_ok(); \
} \
else { \
diff --git a/test/facts_test.c b/test/facts_test.c
index ca9cfc4..546c228 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <unistd.h>
#include "../libc3/buf.h"
+#include "../libc3/compare.h"
#include "../libc3/facts.h"
#include "fact_test.h"
#include "test.h"
@@ -81,15 +82,15 @@ void facts_test_add ()
TEST_ASSERT((pf = facts_add_fact(&facts, fact + i)));
TEST_EQ(facts.tags.count, i + 1);
TEST_EQ(facts.facts.count, i + 1);
- TEST_EQ(tag_compare(fact[i].subject, pf->subject), 0);
- TEST_EQ(tag_compare(fact[i].predicate, pf->predicate), 0);
- TEST_EQ(tag_compare(fact[i].object, pf->object), 0);
+ TEST_EQ(compare_tag(fact[i].subject, pf->subject), 0);
+ TEST_EQ(compare_tag(fact[i].predicate, pf->predicate), 0);
+ TEST_EQ(compare_tag(fact[i].object, pf->object), 0);
TEST_ASSERT((pf = facts_add_fact(&facts, fact + i)));
TEST_EQ(facts.tags.count, i + 1);
TEST_EQ(facts.facts.count, i + 1);
- TEST_EQ(tag_compare(fact[i].subject, pf->subject), 0);
- TEST_EQ(tag_compare(fact[i].predicate, pf->predicate), 0);
- TEST_EQ(tag_compare(fact[i].object, pf->object), 0);
+ TEST_EQ(compare_tag(fact[i].subject, pf->subject), 0);
+ TEST_EQ(compare_tag(fact[i].predicate, pf->predicate), 0);
+ TEST_EQ(compare_tag(fact[i].object, pf->object), 0);
fact_test_clean_1(fact + i);
i++;
}
@@ -185,9 +186,9 @@ void facts_test_find ()
TEST_EQ(facts_find_fact(&facts, fact + i), NULL);
facts_add_fact(&facts, fact + i);
TEST_ASSERT((pf = facts_find_fact(&facts, fact + i)));
- TEST_EQ(tag_compare(fact[i].subject, pf->subject), 0);
- TEST_EQ(tag_compare(fact[i].predicate, pf->predicate), 0);
- TEST_EQ(tag_compare(fact[i].object, pf->object), 0);
+ TEST_EQ(compare_tag(fact[i].subject, pf->subject), 0);
+ TEST_EQ(compare_tag(fact[i].predicate, pf->predicate), 0);
+ TEST_EQ(compare_tag(fact[i].object, pf->object), 0);
i++;
}
while (i--) {
@@ -441,7 +442,7 @@ void facts_test_save ()
facts_add_fact(&facts, fact + i);
i++;
}
- facts_save(&facts, "facts_test_save.facts");
+ facts_save_file(&facts, "facts_test_save.facts");
test_file_compare("facts_test_save.facts",
"facts_test_save.facts.expected");
if (g_test_last_ok)
diff --git a/test/facts_test_dump_file.facts.expected b/test/facts_test_dump_file.facts.expected
index bebffb3..52b1c78 100644
--- a/test/facts_test_dump_file.facts.expected
+++ b/test/facts_test_dump_file.facts.expected
@@ -1,23 +1,27 @@
-add {a, a, a}
-add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
-add {18446744073709551616, 18446744073709551616, 18446744073709551616}
-add {-4294967296, -4294967296, -4294967296}
-add {-65536, -65536, -65536}
-add {-256, -256, -256}
-add {-10, -10, -10}
-add {-1, -1, -1}
-add {0, 0, 0}
-add {1, 1, 1}
-add {10, 10, 10}
-add {256, 256, 256}
-add {65536, 65536, 65536}
-add {4294967296, 4294967296, 4294967296}
-add {[], [], []}
-add {[[], []], [[], []], [[], []]}
-add {"a", "a", "a"}
-add {A, A, A}
-add {:a, :a, :a}
-add {{a, b}, {a, b}, {a, b}}
-add {{:a, :b}, {:a, :b}, {:a, :b}}
-add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
-add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+%{module: C3.Facts.Dump,
+ version: 0x0000000000000001,
+ count: 0x0000000000000017}
+{a, a, a}
+{-18446744073709551616, -18446744073709551616, -18446744073709551616}
+{18446744073709551616, 18446744073709551616, 18446744073709551616}
+{-4294967296, -4294967296, -4294967296}
+{-65536, -65536, -65536}
+{-256, -256, -256}
+{-10, -10, -10}
+{-1, -1, -1}
+{0, 0, 0}
+{1, 1, 1}
+{10, 10, 10}
+{256, 256, 256}
+{65536, 65536, 65536}
+{4294967296, 4294967296, 4294967296}
+{[], [], []}
+{[[], []], [[], []], [[], []]}
+{"a", "a", "a"}
+{A, A, A}
+{:a, :a, :a}
+{{a, b}, {a, b}, {a, b}}
+{{:a, :b}, {:a, :b}, {:a, :b}}
+{{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+{{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+%{hash: 0x12B617E8ED748848}
diff --git a/test/facts_test_save.facts.expected b/test/facts_test_save.facts.expected
index 67fe21b..442f3c6 100644
--- a/test/facts_test_save.facts.expected
+++ b/test/facts_test_save.facts.expected
@@ -1,27 +1,29 @@
-%{count: 0x0000000000000017,
- digest: 0x0000000000000000,
- dump: 0x0000000000000078,
- log: 0x0000000000000349}
-add {a, a, a}
-add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
-add {18446744073709551616, 18446744073709551616, 18446744073709551616}
-add {-4294967296, -4294967296, -4294967296}
-add {-65536, -65536, -65536}
-add {-256, -256, -256}
-add {-10, -10, -10}
-add {-1, -1, -1}
-add {0, 0, 0}
-add {1, 1, 1}
-add {10, 10, 10}
-add {256, 256, 256}
-add {65536, 65536, 65536}
-add {4294967296, 4294967296, 4294967296}
-add {[], [], []}
-add {[[], []], [[], []], [[], []]}
-add {"a", "a", "a"}
-add {A, A, A}
-add {:a, :a, :a}
-add {{a, b}, {a, b}, {a, b}}
-add {{:a, :b}, {:a, :b}, {:a, :b}}
-add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
-add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+%{module: C3.Facts.Save,
+ version: 0x0000000000000001}
+%{module: C3.Facts.Dump,
+ version: 0x0000000000000001,
+ count: 0x0000000000000017}
+{a, a, a}
+{-18446744073709551616, -18446744073709551616, -18446744073709551616}
+{18446744073709551616, 18446744073709551616, 18446744073709551616}
+{-4294967296, -4294967296, -4294967296}
+{-65536, -65536, -65536}
+{-256, -256, -256}
+{-10, -10, -10}
+{-1, -1, -1}
+{0, 0, 0}
+{1, 1, 1}
+{10, 10, 10}
+{256, 256, 256}
+{65536, 65536, 65536}
+{4294967296, 4294967296, 4294967296}
+{[], [], []}
+{[[], []], [[], []], [[], []]}
+{"a", "a", "a"}
+{A, A, A}
+{:a, :a, :a}
+{{a, b}, {a, b}, {a, b}}
+{{:a, :b}, {:a, :b}, {:a, :b}}
+{{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+{{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+%{hash: 0x12B617E8ED748848}
diff --git a/test/libc3_test.c b/test/libc3_test.c
index 058f3fc..03ee95e 100644
--- a/test/libc3_test.c
+++ b/test/libc3_test.c
@@ -21,10 +21,9 @@ void buf_parse_test ();
void buf_test ();
void call_test ();
void character_test ();
+void compare_test ();
void fact_test ();
void facts_test ();
-void f32_test ();
-void f64_test ();
void facts_cursor_test ();
void facts_with_test ();
void ident_test ();
@@ -102,9 +101,9 @@ int main (int argc, char **argv)
printf("\nfact\n");
fact_test();
}
- if (test_target("f64")) {
- printf("\nf64\n");
- f64_test();
+ if (test_target("compare")) {
+ printf("\ncompare\n");
+ compare_test();
}
if (test_target("set__tag")) {
printf("\nset__tag\n");
@@ -130,10 +129,6 @@ int main (int argc, char **argv)
printf("\nfacts_with\n");
facts_with_test();
}
- if (test_target("f32")) {
- printf("\nf32\n");
- f32_test();
- }
test_summary();
test_shutdown();
libc3_shutdown();
diff --git a/test/list_test.c b/test/list_test.c
index 5f6569d..4a8a827 100644
--- a/test/list_test.c
+++ b/test/list_test.c
@@ -27,16 +27,6 @@
test_context(NULL); \
} while (0)
-#define LIST_TEST_COMPARE(a, b, expected) \
- do { \
- s_list *tmp_a = (a); \
- s_list *tmp_b = (b); \
- test_context("list_compare(" # a ", " # b ") -> " # expected); \
- TEST_EQ(list_compare(tmp_a, tmp_b), (expected)); \
- list_delete(tmp_a); \
- list_delete(tmp_b); \
- } while (0)
-
#define LIST_TEST_INSPECT(test, expected) \
do { \
s_list *list_test; \
@@ -52,14 +42,12 @@
void list_test ();
void list_test_1 ();
-void list_test_compare ();
void list_test_inspect ();
void list_test ()
{
list_test_1();
list_test_inspect();
- list_test_compare();
}
void list_test_1 ()
@@ -76,13 +64,6 @@ void list_test_1 ()
LIST_TEST_1("[A, B, C | D]");
}
-void list_test_compare ()
-{
- LIST_TEST_COMPARE(NULL, NULL, 0);
- LIST_TEST_COMPARE(list_1("[A, B]"), list_1("[A, C]"), -1);
- LIST_TEST_COMPARE(list_1("[A, C]"), list_1("[A, B]"), 1);
-}
-
void list_test_inspect ()
{
LIST_TEST_INSPECT("[]", "[]");
diff --git a/test/str_test.c b/test/str_test.c
index b85373c..f8fcb6a 100644
--- a/test/str_test.c
+++ b/test/str_test.c
@@ -14,31 +14,10 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include "compare_test.h"
#include "../libc3/str.h"
#include "test.h"
-#define STR_TEST_CMP(a, b, expected) \
- do { \
- s_str *a_ = (a); \
- s_str *b_ = (b); \
- sw tmp = str_compare(a_, b_); \
- str_delete(a_); \
- str_delete(b_); \
- if (tmp == expected) { \
- test_ok(); \
- } \
- else { \
- test_ko(); \
- printf("\n%sAssertion failed in %s:%d %s\n" \
- "str_compare(%s, %s) == %s\n" \
- "Expected %s got %ld.%s\n", \
- TEST_COLOR_KO, \
- __FILE__, __LINE__, __func__, \
- # a, # b, # expected, # expected, tmp, \
- TEST_COLOR_RESET); \
- } \
- } while (0)
-
#define STR_TEST_INSPECT(test, expected) \
do { \
s_str *str_test; \
@@ -79,11 +58,10 @@
str_init_1(&str, NULL, (test)); \
TEST_ASSERT((result = str_to_sym(&str))); \
TEST_EQ(str_to_sym(&str), result); \
- TEST_STR_CMP(&result->str, &str, 0); \
+ COMPARE_TEST_STR(&result->str, &str, 0); \
} while (0)
void str_test_character_is_reserved ();
-void str_test_compare ();
void str_test_init_clean ();
void str_test_init_dup ();
void str_test_init_dup_1 ();
@@ -106,7 +84,6 @@ void str_test ()
str_test_new_delete();
str_test_new_1();
str_test_new_dup();
- str_test_compare();
str_test_new_cpy();
str_test_new_f();
str_test_character_is_reserved();
@@ -149,33 +126,6 @@ void str_test_character_is_reserved ()
TEST_ASSERT(str_character_is_reserved('\\'));
}
-void str_test_compare ()
-{
- s_str *a;
- TEST_EQ((a = str_new_empty(), str_compare(a, a)), 0);
- str_delete(a);
- TEST_EQ((a = str_new_1(NULL, "abc"), str_compare(a, a)), 0);
- str_delete(a);
- STR_TEST_CMP(str_new_empty(), str_new_empty(), 0);
- STR_TEST_CMP(str_new_empty(), str_new_1(NULL, "0"), -1);
- STR_TEST_CMP(str_new_1(NULL, "0"), str_new_empty(), 1);
- STR_TEST_CMP(str_new_1(NULL, "0"), str_new_1(NULL, "0"), 0);
- STR_TEST_CMP(str_new_1(NULL, "0"), str_new_1(NULL, "A"), -1);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "0"), 1);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "01"), 0);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "012"), -1);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "02"), -1);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "023"), -1);
- STR_TEST_CMP(str_new_1(NULL, "01"), str_new_1(NULL, "ABC"), -1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "0"), 1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "01"), 1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "012"), 0);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "0123"), -1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "013"), -1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "0134"), -1);
- STR_TEST_CMP(str_new_1(NULL, "012"), str_new_1(NULL, "ABC"), -1);
-}
-
void str_test_init_clean ()
{
size_t len;
diff --git a/test/tag_test.c b/test/tag_test.c
index 9b2ee1c..0ac0e00 100644
--- a/test/tag_test.c
+++ b/test/tag_test.c
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include "../libc3/tag.h"
+#include "../libc3/compare.h"
#include "test.h"
#define TAG_TEST_HASH_U64_COMPARE(a, b, expected) \
@@ -24,23 +25,23 @@
} while (0)
void tag_test ();
-void tag_test_hash ();
+void tag_test_hash_u64 ();
void tag_test ()
{
- tag_test_hash();
+ tag_test_hash_u64();
}
-void tag_test_hash ()
+void tag_test_hash_u64 ()
{
s_tag a;
s_tag b;
tag_init_1(&a, "{a, b}");
- TAG_TEST_HASH_COMPARE(&a, &a, 0);
- TAG_TEST_HASH_COMPARE(tag_1(&a, "{a, b}"), tag_init_1(&b, "{a, b}"), 0);
- TAG_TEST_HASH_COMPARE(tag_1(&a, "{a, b}"), tag_1(&b, "{a, b}"), 0);
- TAG_TEST_HASH_COMPARE(tag_1(&a, "{{a, b}, {c, d}}"),
- tag_1(&b, "{{a, b}, {c, d}}"), 0);
+ TAG_TEST_HASH_U64_COMPARE(&a, &a, 0);
+ TAG_TEST_HASH_U64_COMPARE(tag_1(&a, "{a, b}"), tag_init_1(&b, "{a, b}"), 0);
+ TAG_TEST_HASH_U64_COMPARE(tag_1(&a, "{a, b}"), tag_1(&b, "{a, b}"), 0);
+ TAG_TEST_HASH_U64_COMPARE(tag_1(&a, "{{a, b}, {c, d}}"),
+ tag_1(&b, "{{a, b}, {c, d}}"), 0);
tag_clean(&a);
tag_clean(&b);
}
diff --git a/test/tag_test.h b/test/tag_test.h
index 6ba2920..110a4c8 100644
--- a/test/tag_test.h
+++ b/test/tag_test.h
@@ -22,7 +22,7 @@
const s_tag *tag_test; \
tag_expected = (expected); \
tag_test = (test); \
- if (tag_compare(tag_test, tag_expected) == 0) { \
+ if (compare_tag(tag_test, tag_expected) == 0) { \
test_ok(); \
} \
else { \
diff --git a/test/tuple_test.c b/test/tuple_test.c
index fb653cf..2c3f397 100644
--- a/test/tuple_test.c
+++ b/test/tuple_test.c
@@ -18,13 +18,6 @@
#include "../libc3/str.h"
#include "test.h"
-#define TUPLE_TEST_COMPARE(a, b, expected) \
- do { \
- test_context("tuple_compare(" # a ", " # b ") -> " # expected); \
- TEST_EQ(tuple_compare((a), (b)), (expected)); \
- test_context(NULL); \
- } while (0)
-
#define TUPLE_TEST_INIT_CLEAN(test) \
do { \
s_tuple tuple_test; \
@@ -81,7 +74,6 @@
} while (0)
void tuple_test ();
-void tuple_test_compare ();
void tuple_test_init_1 ();
void tuple_test_init_clean ();
void tuple_test_inspect ();
@@ -94,37 +86,9 @@ void tuple_test ()
tuple_test_new_delete();
tuple_test_init_1();
tuple_test_new_1();
- tuple_test_compare();
tuple_test_inspect();
}
-void tuple_test_compare ()
-{
- s_tuple a;
- s_tuple b;
- TUPLE_TEST_COMPARE(tuple_init_1(&a, "{A, B}"),
- tuple_init_1(&b, "{A, B}"), 0);
- TUPLE_TEST_COMPARE(&a, &a, 0);
- tuple_clean(&a);
- tuple_clean(&b);
- TUPLE_TEST_COMPARE(tuple_init_1(&a, "{A, A}"),
- tuple_init_1(&b, "{A, B}"), -1);
- tuple_clean(&a);
- tuple_clean(&b);
- TUPLE_TEST_COMPARE(tuple_init_1(&a, "{A, B}"),
- tuple_init_1(&b, "{A, A}"), 1);
- tuple_clean(&a);
- tuple_clean(&b);
- TUPLE_TEST_COMPARE(tuple_init_1(&a, "{A, B}"),
- tuple_init_1(&b, "{A, B, C}"), -1);
- tuple_clean(&a);
- tuple_clean(&b);
- TUPLE_TEST_COMPARE(tuple_init_1(&a, "{A, B, C}"),
- tuple_init_1(&b, "{A, B}"), 1);
- tuple_clean(&a);
- tuple_clean(&b);
-}
-
void tuple_test_init_clean ()
{
TUPLE_TEST_INIT_CLEAN(2);