[llvm] [APFloat] Add APFloat::format (PR #99088)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 00:28:52 PDT 2024


================
@@ -1378,6 +1378,171 @@ TEST(APFloatTest, toString) {
   }
 }
 
+TEST(APFloatTest, format) {
+  auto doit_precision = [](const fltSemantics &S, const char *value,
+                           llvm::FloatStyle style, int precision,
+                           const char *expected) {
+    SmallString<16> s;
+    APFloat apf(S, value);
+    apf.format(s, style, precision);
+    EXPECT_STREQ(expected, s.c_str());
----------------
arsenm wrote:

```suggestion
    EXPECT_EQ(expected, s);
```

Regular EXPECT_EQ should work fine with StringRef + SmallString 

https://github.com/llvm/llvm-project/pull/99088


More information about the llvm-commits mailing list