#include "folly/FBString.h"
+#include <cstdlib>
+
#include <list>
#include <fstream>
#include <boost/algorithm/string.hpp>
laoreet. Phasellus lectus quam, ultricies ut tincidunt in, dignissim \n\
id eros. Mauris vulputate tortor nec neque pellentesque sagittis quis \n\
sed nisl. In diam lacus, lobortis ut posuere nec, ornare id quam.";
- const char* f = "/tmp/fbstring_testing";
- {
+ char f[] = "/tmp/fbstring_testing.XXXXXX";
+ int fd = mkstemp(f);
+ EXPECT_TRUE(fd > 0);
+ if (fd > 0) {
+ close(fd); // Yeah
std::ofstream out(f);
if (!(out << s1)) {
EXPECT_TRUE(0) << "Couldn't write to temp file.";
}
vector<fbstring> v;
boost::split(v, s1, boost::is_any_of("\n"));
- ifstream input(f);
- fbstring line;
- FOR_EACH (i, v) {
- EXPECT_TRUE(getline(input, line));
- EXPECT_EQ(line, *i);
+ {
+ ifstream input(f);
+ fbstring line;
+ FOR_EACH (i, v) {
+ EXPECT_TRUE(getline(input, line));
+ EXPECT_EQ(line, *i);
+ }
}
+ unlink(f);
}
TEST(FBString, testMoveCtor) {