aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2016-12-14 14:18:34 +0000
committerGravatar John Cater <jcater@google.com>2016-12-14 20:18:22 +0000
commit54f402083a799228660c3de63c4011e0921e257a (patch)
tree0587da4bd0a572b71af496a1d958cd740ea4b6b4 /src/test/cpp
parent79fdab0dd4d04ab87bf27abbb1b12a09aae5b82b (diff)
Bazel client: implement Cstring-Wstring conversion
Implement conversion methods between char strings and wchar_t strings. This is necessary to use widechar Windows functions. See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142009930 MOS_MIGRATED_REVID=142009930
Diffstat (limited to 'src/test/cpp')
-rw-r--r--src/test/cpp/util/strings_test.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/cpp/util/strings_test.cc b/src/test/cpp/util/strings_test.cc
index 91c7f9c2c3..ffdf89e27b 100644
--- a/src/test/cpp/util/strings_test.cc
+++ b/src/test/cpp/util/strings_test.cc
@@ -12,11 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/main/cpp/util/strings.h"
+
+#include <wchar.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
#include "gtest/gtest.h"
namespace blaze_util {
using std::string;
+using std::unique_ptr;
using std::vector;
TEST(BlazeUtil, JoinStrings) {
@@ -295,4 +303,14 @@ TEST(BlazeUtil, StringPrintf) {
EXPECT_EQ("a b", out);
}
+TEST(BlazeUtil, CstringToWstringTest) {
+ unique_ptr<wchar_t[]> actual = CstringToWstring("hello world");
+ EXPECT_EQ(0, wcscmp(actual.get(), L"hello world"));
+}
+
+TEST(BlazeUtil, WstringToCstringTest) {
+ unique_ptr<char[]> actual = WstringToCstring(L"hello world");
+ EXPECT_EQ(0, strcmp(actual.get(), "hello world"));
+}
+
} // namespace blaze_util