OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/shared/asan_helper.h" | 7 #include "src/shared/asan_helper.h" |
8 #include "src/shared/assert.h" | 8 #include "src/shared/assert.h" |
9 #include "src/shared/flags.h" | 9 #include "src/shared/flags.h" |
10 #include "src/shared/test_case.h" | 10 #include "src/shared/test_case.h" |
11 | 11 |
12 static const int argc = 3; | 12 static const int argc = 3; |
13 static const char* argv[argc] = { | 13 static const char* argv[argc] = { |
14 "fletch", "-Xverbose", "nothing", | 14 "dartino", "-Xverbose", "nothing", |
15 }; | 15 }; |
16 | 16 |
17 namespace fletch { | 17 namespace dartino { |
18 | 18 |
19 TEST_CASE(Arguments) { | 19 TEST_CASE(Arguments) { |
20 #ifdef USING_ADDRESS_SANITIZER | 20 #ifdef USING_ADDRESS_SANITIZER |
21 __lsan_disable(); | 21 __lsan_disable(); |
22 #endif | 22 #endif |
23 // Make a copy of the arguments. This is necessary | 23 // Make a copy of the arguments. This is necessary |
24 // because Flags::ExtractFromCommandLine modifies the arguments. | 24 // because Flags::ExtractFromCommandLine modifies the arguments. |
25 char** values = reinterpret_cast<char**>(calloc(sizeof(char*), argc)); | 25 char** values = reinterpret_cast<char**>(calloc(sizeof(char*), argc)); |
26 for (int i = 0; i < argc; i++) { | 26 for (int i = 0; i < argc; i++) { |
27 values[i] = reinterpret_cast<char*>(malloc(strlen(argv[i]) + 1)); | 27 values[i] = reinterpret_cast<char*>(malloc(strlen(argv[i]) + 1)); |
28 strcpy(values[i], argv[i]); // NOLINT | 28 strcpy(values[i], argv[i]); // NOLINT |
29 } | 29 } |
30 #ifdef USING_ADDRESS_SANITIZER | 30 #ifdef USING_ADDRESS_SANITIZER |
31 __lsan_enable(); | 31 __lsan_enable(); |
32 #endif | 32 #endif |
33 | 33 |
34 // Parse the fake arguments | 34 // Parse the fake arguments |
35 int count = argc; | 35 int count = argc; |
36 Flags::ExtractFromCommandLine(&count, values); | 36 Flags::ExtractFromCommandLine(&count, values); |
37 EXPECT_EQ(2, count); | 37 EXPECT_EQ(2, count); |
38 EXPECT_STREQ("fletch", values[0]); | 38 EXPECT_STREQ("dartino", values[0]); |
39 EXPECT_STREQ("nothing", values[1]); | 39 EXPECT_STREQ("nothing", values[1]); |
40 EXPECT(Flags::verbose); | 40 EXPECT(Flags::verbose); |
41 } | 41 } |
42 | 42 |
43 } // namespace fletch | 43 } // namespace dartino |
OLD | NEW |