Skip to content

Commit 3048d63

Browse files
Update test_jellyfish.c
1 parent 307c0f1 commit 3048d63

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

code/tests/cases/test_jellyfish.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,35 @@ FOSSIL_TEST_CASE(c_test_jellyfish_chain_hash_stability) {
121121
FOSSIL_TEST_CASE(c_test_jellyfish_chain_save_and_load) {
122122
fossil_jellyfish_chain chain = {0};
123123
fossil_jellyfish_init(&chain);
124+
125+
// Learn two entries
124126
fossil_jellyfish_learn(&chain, "input1", "output1");
125127
fossil_jellyfish_learn(&chain, "input2", "output2");
126128

129+
// Optionally set confidence for verification
130+
chain.memory[0].confidence = 0.9f;
131+
chain.memory[1].confidence = 0.7f;
132+
127133
const char *filename = "test_jellyfish_save_load.jellyfish";
134+
128135
int save_result = fossil_jellyfish_save(&chain, filename);
129136
ASSUME_ITS_TRUE(save_result == 1);
130137

131138
fossil_jellyfish_chain loaded = {0};
132139
int load_result = fossil_jellyfish_load(&loaded, filename);
133140
ASSUME_ITS_TRUE(load_result == 1);
141+
142+
// Verify chain structure
134143
ASSUME_ITS_EQUAL_SIZE(loaded.count, 2);
135144
ASSUME_ITS_EQUAL_CSTR(loaded.memory[0].input, "input1");
145+
ASSUME_ITS_EQUAL_CSTR(loaded.memory[0].output, "output1");
146+
ASSUME_ITS_EQUAL_CSTR(loaded.memory[1].input, "input2");
136147
ASSUME_ITS_EQUAL_CSTR(loaded.memory[1].output, "output2");
137148

149+
// Check confidence float values with a small tolerance
150+
ASSUME_ITS_TRUE(fabsf(loaded.memory[0].confidence - 0.9f) < 0.01f);
151+
ASSUME_ITS_TRUE(fabsf(loaded.memory[1].confidence - 0.7f) < 0.01f);
152+
138153
remove(filename);
139154
}
140155

@@ -208,9 +223,16 @@ FOSSIL_TEST_CASE(c_test_jellyfish_best_memory) {
208223

209224
FOSSIL_TEST_CASE(c_test_jellyfish_detect_conflict) {
210225
fossil_jellyfish_chain chain = {0};
226+
fossil_jellyfish_init(&chain);
227+
228+
// Teach it one input-output pair
211229
fossil_jellyfish_learn(&chain, "foo", "bar");
230+
231+
// Introduce a conflicting input with different output
212232
int conflict = fossil_jellyfish_detect_conflict(&chain, "foo", "baz");
213-
ASSUME_ITS_TRUE(conflict == 0); // Not implemented, always returns 0
233+
234+
// Currently a stub (always returns 0)
235+
ASSUME_ITS_TRUE(conflict == 0);
214236
}
215237

216238
FOSSIL_TEST_CASE(c_test_jellyfish_knowledge_coverage) {

0 commit comments

Comments
 (0)