| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/directory.h" | 5 #include "bin/directory.h" |
| 6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const char* new_current = dart::bin::Directory::Current(); | 77 const char* new_current = dart::bin::Directory::Current(); |
| 78 EXPECT_NOTNULL(new_current); | 78 EXPECT_NOTNULL(new_current); |
| 79 | 79 |
| 80 EXPECT_NOTNULL(strstr(new_current, system_temp)); | 80 EXPECT_NOTNULL(strstr(new_current, system_temp)); |
| 81 | 81 |
| 82 EXPECT(dart::bin::Directory::SetCurrent(current)); | 82 EXPECT(dart::bin::Directory::SetCurrent(current)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 TEST_CASE(DirectoryCreateDelete) { | 86 TEST_CASE(DirectoryCreateDelete) { |
| 87 const char* kTempDirName = "test_name"; | 87 const char* kTempDirName = "create_delete_test_name"; |
| 88 | 88 |
| 89 const char* system_temp = dart::bin::Directory::SystemTemp(); | 89 const char* system_temp = dart::bin::Directory::SystemTemp(); |
| 90 EXPECT_NOTNULL(system_temp); | 90 EXPECT_NOTNULL(system_temp); |
| 91 | 91 |
| 92 const intptr_t name_len = | 92 const intptr_t name_len = |
| 93 snprintf(NULL, 0, "%s/%s", system_temp, kTempDirName); | 93 snprintf(NULL, 0, "%s/%s", system_temp, kTempDirName); |
| 94 ASSERT(name_len > 0); | 94 ASSERT(name_len > 0); |
| 95 char* name = new char[name_len + 1]; | 95 char* name = new char[name_len + 1]; |
| 96 snprintf(name, name_len + 1, "%s/%s", system_temp, kTempDirName); | 96 snprintf(name, name_len + 1, "%s/%s", system_temp, kTempDirName); |
| 97 | 97 |
| 98 // Make a directory. | 98 // Make a directory. |
| 99 EXPECT(dart::bin::Directory::Create(name)); | 99 EXPECT(dart::bin::Directory::Create(name)); |
| 100 | 100 |
| 101 // Make sure it exists. | 101 // Make sure it exists. |
| 102 dart::bin::Directory::ExistsResult r = dart::bin::Directory::Exists(name); | 102 dart::bin::Directory::ExistsResult r = dart::bin::Directory::Exists(name); |
| 103 EXPECT_EQ(dart::bin::Directory::EXISTS, r); | 103 EXPECT_EQ(dart::bin::Directory::EXISTS, r); |
| 104 | 104 |
| 105 // Cleanup. | 105 // Cleanup. |
| 106 EXPECT(dart::bin::Directory::Delete(name, false)); | 106 EXPECT(dart::bin::Directory::Delete(name, false)); |
| 107 delete[] name; | 107 delete[] name; |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 TEST_CASE(DirectoryRename) { | 111 TEST_CASE(DirectoryRename) { |
| 112 const char* kTempDirName = "test_name"; | 112 const char* kTempDirName = "rename_test_name"; |
| 113 | 113 |
| 114 const char* system_temp = dart::bin::Directory::SystemTemp(); | 114 const char* system_temp = dart::bin::Directory::SystemTemp(); |
| 115 EXPECT_NOTNULL(system_temp); | 115 EXPECT_NOTNULL(system_temp); |
| 116 | 116 |
| 117 const intptr_t name_len = | 117 const intptr_t name_len = |
| 118 snprintf(NULL, 0, "%s/%s", system_temp, kTempDirName); | 118 snprintf(NULL, 0, "%s/%s", system_temp, kTempDirName); |
| 119 ASSERT(name_len > 0); | 119 ASSERT(name_len > 0); |
| 120 char* name = new char[name_len + 1]; | 120 char* name = new char[name_len + 1]; |
| 121 snprintf(name, name_len + 1, "%s/%s", system_temp, kTempDirName); | 121 snprintf(name, name_len + 1, "%s/%s", system_temp, kTempDirName); |
| 122 | 122 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 r = dart::bin::Directory::Exists(name); | 142 r = dart::bin::Directory::Exists(name); |
| 143 EXPECT_EQ(dart::bin::Directory::DOES_NOT_EXIST, r); | 143 EXPECT_EQ(dart::bin::Directory::DOES_NOT_EXIST, r); |
| 144 | 144 |
| 145 EXPECT(dart::bin::Directory::Delete(new_name, false)); | 145 EXPECT(dart::bin::Directory::Delete(new_name, false)); |
| 146 delete[] name; | 146 delete[] name; |
| 147 delete[] new_name; | 147 delete[] new_name; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace dart | 150 } // namespace dart |
| OLD | NEW |