diff options
author | Michael Jones <michaelrj@google.com> | 2022-11-08 01:02:32 +0300 |
---|---|---|
committer | Michael Jones <michaelrj@google.com> | 2022-11-08 01:04:39 +0300 |
commit | 430ca14af835a4d8ea927ed6550a99242bebf255 (patch) | |
tree | 81a8aa7bbd1d90df5f2cca82916b98183f7686e0 /libc | |
parent | 86674f66cc78a1a121d43fe51f076cbfa8710b1a (diff) |
[libc][obvious] fix tests using wrong size for string
In the code
const char *str = "abc"
if you do sizeof(str) you get the size of the pointer, not the string.
This patch fixes that mistake.
Differential Revision: https://reviews.llvm.org/D137586
Diffstat (limited to 'libc')
-rw-r--r-- | libc/test/src/stdio/scanf_core/string_reader_test.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/test/src/stdio/scanf_core/string_reader_test.cpp b/libc/test/src/stdio/scanf_core/string_reader_test.cpp index 43e65cc1bab6..4331d488be06 100644 --- a/libc/test/src/stdio/scanf_core/string_reader_test.cpp +++ b/libc/test/src/stdio/scanf_core/string_reader_test.cpp @@ -23,7 +23,7 @@ TEST(LlvmLibcScanfStringReaderTest, SimpleRead) { __llvm_libc::scanf_core::StringReader str_reader(str); __llvm_libc::scanf_core::Reader reader(&str_reader); - for (size_t i = 0; i < sizeof(str); ++i) { + for (size_t i = 0; i < sizeof("abc"); ++i) { ASSERT_EQ(str[i], reader.getc()); } } @@ -60,7 +60,7 @@ TEST(LlvmLibcScanfStringReaderTest, ReadAndReverse) { } // Check the whole string. - for (size_t i = 0; i < sizeof(str); ++i) { + for (size_t i = 0; i < sizeof("abcDEF123"); ++i) { ASSERT_EQ(str[i], reader.getc()); } } |