diff --git a/ReactCommon/cxxreact/tests/BUCK b/ReactCommon/cxxreact/tests/BUCK index e9ae81aa21a..b123414e910 100644 --- a/ReactCommon/cxxreact/tests/BUCK +++ b/ReactCommon/cxxreact/tests/BUCK @@ -55,3 +55,17 @@ fb_xplat_cxx_test( react_native_xplat_target("cxxreact:jsbigstring"), ], ) + +fb_xplat_cxx_test( + name = "jsbigstring_test", + srcs = ["jsbigstring.cpp"], + compiler_flags = [ + "-fexceptions", + "-frtti", + ], + deps = [ + "fbsource//xplat/folly:molly", + "fbsource//xplat/third-party/gmock:gtest", + react_native_xplat_target("cxxreact:jsbigstring"), + ], +) diff --git a/ReactCommon/cxxreact/tests/jsbigstring.cpp b/ReactCommon/cxxreact/tests/jsbigstring.cpp index 69e265c96f0..a8f58f16646 100644 --- a/ReactCommon/cxxreact/tests/jsbigstring.cpp +++ b/ReactCommon/cxxreact/tests/jsbigstring.cpp @@ -15,7 +15,10 @@ using namespace facebook::react; namespace { int tempFileFromString(std::string contents) { - std::string tmp {getenv("TMPDIR")}; + const char *tmpDir = getenv("TMPDIR"); + if (tmpDir == nullptr) + tmpDir = "/tmp"; + std::string tmp {tmpDir}; tmp += "/temp.XXXXXX"; std::vector tmpBuf {tmp.begin(), tmp.end()};