@@ -133,6 +133,86 @@ bool closed_test3() {
133133 return true ;
134134}
135135
136+ int read_value_without_find_test () {
137+ uCDB<SdFat, File> ucdb (fat);
138+ byte buff[64 ];
139+
140+ if (ucdb.open (" airports.cdb" ) != CDB_OK) {
141+ ucdb.close ();
142+ return -1 ;
143+ }
144+
145+ if (ucdb.state () != CDB_OK)
146+ return -100 ;
147+
148+ if (ucdb.valueAvailable () != 0 )
149+ return -2 ;
150+ if (ucdb.readValue () != -1 )
151+ return -3 ;
152+ if (ucdb.readValue (buff, 1 ) != -1 )
153+ return -4 ;
154+
155+ return 1 ;
156+ }
157+
158+ int read_value_find_fail_test () {
159+ uCDB<SdFat, File> ucdb (fat);
160+ byte buff[64 ];
161+
162+ if (ucdb.open (" airports.cdb" ) != CDB_OK) {
163+ ucdb.close ();
164+ return -1 ;
165+ }
166+
167+ if (ucdb.state () != CDB_OK)
168+ return -100 ;
169+
170+ if (ucdb.findKey (" AAAAAAAA" , 8 ) != KEY_NOT_FOUND)
171+ return -2 ;
172+
173+ if (ucdb.valueAvailable () != 0 )
174+ return -3 ;
175+ if (ucdb.readValue () != -1 )
176+ return -4 ;
177+ if (ucdb.readValue (buff, 1 ) != -1 )
178+ return -5 ;
179+
180+ return 1 ;
181+ }
182+
183+ int read_value_find_ok_test () {
184+ uCDB<SdFat, File> ucdb (fat);
185+ byte buff[64 ];
186+
187+ if (ucdb.open (" airports.cdb" ) != CDB_OK) {
188+ ucdb.close ();
189+ return -1 ;
190+ }
191+
192+ if (ucdb.state () != CDB_OK)
193+ return -100 ;
194+
195+ if (ucdb.findKey (" ZYGH" , 4 ) != KEY_FOUND)
196+ return -2 ;
197+
198+ if (ucdb.valueAvailable () <= 0 )
199+ return -3 ;
200+
201+ while (ucdb.readValue () >= 0 );
202+
203+ if (ucdb.valueAvailable () != 0 )
204+ return -4 ;
205+
206+ if (ucdb.readValue () != -1 )
207+ return -5 ;
208+ if (ucdb.readValue (buff, 1 ) != 0 )
209+ return -6 ;
210+ if (ucdb.valueAvailable () != 0 )
211+ return -7 ;
212+
213+ return 1 ;
214+ }
215+
136216bool random_test1 () {
137217 uCDB<SdFat, File> ucdb (fat);
138218 byte buff[64 ];
@@ -315,6 +395,16 @@ void loop() {
315395 Serial.println (closed_test1 ());
316396 Serial.println (closed_test2 ());
317397 Serial.println (closed_test3 ());
398+
399+ Serial.println (" read_value_without_find_test" );
400+ Serial.println (read_value_without_find_test ());
401+
402+ Serial.println (" read_value_find_fail_test" );
403+ Serial.println (read_value_find_fail_test ());
404+
405+ Serial.println (" read_value_find_ok_test" );
406+ Serial.println (read_value_find_ok_test ());
407+
318408 Serial.println (random_test1 ());
319409 Serial.println (random_test2 ());
320410 Serial.println (random_test3 ());
0 commit comments