Add a formatter for folly::StringPiece
This commit is contained in:
@@ -86,6 +86,7 @@ endfunction()
|
||||
|
||||
add_fmt_test(assert-test)
|
||||
add_fmt_test(gtest-extra-test)
|
||||
add_fmt_test(folly-test)
|
||||
add_fmt_test(format-test)
|
||||
add_fmt_test(format-impl-test)
|
||||
add_fmt_test(ostream-test)
|
||||
|
||||
14
test/folly-test.cc
Normal file
14
test/folly-test.cc
Normal file
@@ -0,0 +1,14 @@
|
||||
// Formatting library for C++ - folly::StringPiece formatter tests
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#include <fmt/folly.h>
|
||||
#include "gtest.h"
|
||||
|
||||
TEST(FollyTest, FormatStringPiece) {
|
||||
EXPECT_EQ(fmt::format("{}", "foo"), "foo");
|
||||
EXPECT_EQ(fmt::format("{:>5}", "foo"), " foo");
|
||||
}
|
||||
17
test/folly/Range.h
Normal file
17
test/folly/Range.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// A folly::StringPiece stub.
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace folly {
|
||||
class StringPiece {
|
||||
public:
|
||||
explicit StringPiece(const char *s) : data_(s), size_(std::strlen(s)) {}
|
||||
|
||||
const char* data() const { return "foo"; }
|
||||
size_t size() const { return 3; }
|
||||
|
||||
private:
|
||||
const char *data_;
|
||||
size_t size_;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user