|
| 1 | +#include <SD.h> |
| 2 | +#include <ArduinoTestSuite.h> |
| 3 | + |
| 4 | +void setup() |
| 5 | +{ |
| 6 | + int startMemoryUsage = ATS_GetFreeMemory(); |
| 7 | + boolean b; |
| 8 | + File f; |
| 9 | + |
| 10 | + ATS_begin("Arduino", "SD Files Test"); |
| 11 | + |
| 12 | + ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); |
| 13 | + if (!b) goto done; |
| 14 | + |
| 15 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); |
| 16 | + ATS_PrintTestStatus("SD.open()", f = SD.open("asdf.txt", true)); f.close(); |
| 17 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf.txt")); |
| 18 | + ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf.txt")); |
| 19 | + ATS_PrintTestStatus("SD.remove()", SD.remove("asdf.txt")); |
| 20 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); |
| 21 | + |
| 22 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); |
| 23 | + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); |
| 24 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); |
| 25 | + ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf")); |
| 26 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/")); |
| 27 | + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); |
| 28 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); |
| 29 | + |
| 30 | + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("x/y/z")); |
| 31 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); |
| 32 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/")); |
| 33 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); |
| 34 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/")); |
| 35 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z")); |
| 36 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z/")); |
| 37 | + ATS_PrintTestStatus("SD.exists()", SD.exists("/x/y/z/")); |
| 38 | + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/z")); |
| 39 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); |
| 40 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); |
| 41 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); |
| 42 | + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/")); |
| 43 | + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); |
| 44 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); |
| 45 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); |
| 46 | + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("/x")); |
| 47 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x")); |
| 48 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); |
| 49 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); |
| 50 | + |
| 51 | + ATS_PrintTestStatus("!SD.open()", !(f = SD.open("asdf/asdf.txt", true))); f.close(); |
| 52 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); |
| 53 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); |
| 54 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); |
| 55 | + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); |
| 56 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); |
| 57 | + ATS_PrintTestStatus("SD.open()", f = SD.open("asdf/asdf.txt", true)); f.close(); |
| 58 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); |
| 59 | + ATS_PrintTestStatus("!SD.rmdir()", !SD.rmdir("asdf")); |
| 60 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); |
| 61 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); |
| 62 | + ATS_PrintTestStatus("SD.remove()", SD.remove("asdf/asdf.txt")); |
| 63 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); |
| 64 | + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); |
| 65 | + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); |
| 66 | + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); |
| 67 | + |
| 68 | +done: |
| 69 | + ATS_ReportMemoryUsage(startMemoryUsage); |
| 70 | + ATS_end(); |
| 71 | + |
| 72 | +} |
| 73 | + |
| 74 | +void loop() {} |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
0 commit comments