1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Add test for FS::open("w+") (#7241)

Verify that a file is truncated on opening with w+ even if no data is
written to it, for all FSes.

Co-authored-by: Develo <deveyes@gmail.com>
This commit is contained in:
Earle F. Philhower, III 2020-04-22 17:24:56 -07:00 committed by GitHub
parent 368ca91869
commit 2de9242b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,6 +161,19 @@ TEST_CASE(TESTPRE "truncate", TESTPAT)
REQUIRE( s == "some" );
}
TEST_CASE(TESTPRE "open(w+) truncates file", TESTPAT)
{
FS_MOCK_DECLARE(64, 8, 512, "");
REQUIRE(FSTYPE.begin());
createFile("/file1", "some text");
String s = readFile("/file1");
REQUIRE( s == "some text");
auto f = FSTYPE.open("/file1", "w+");
f.close();
String t = readFile("/file1");
REQUIRE( t == "");
}
#ifdef FS_HAS_DIRS
#if FSTYPE != SDFS