[libcxx-commits] [libcxx] gcd: Add more tests that require few more divisions (PR #129395)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 1 10:53:12 PST 2025


https://github.com/hiraditya updated https://github.com/llvm/llvm-project/pull/129395

>From d245bea8d51d0e5c02b86f94eb4778a3a9e1ab5c Mon Sep 17 00:00:00 2001
From: AdityaK <hiraditya at msn.com>
Date: Sat, 1 Mar 2025 10:39:47 -0800
Subject: [PATCH] gcd: Add more tests that require few more divisions

@colincross identified gcd does not have a single case whose answer is not 0, 1, or the smaller of the two inputs.
---
 .../numeric.ops/numeric.ops.gcd/gcd.pass.cpp       | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
index 975b53a763afa..44335d98a3f15 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
@@ -27,7 +27,19 @@ constexpr struct {
   int x;
   int y;
   int expect;
-} Cases[] = {{0, 0, 0}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}, {2, 3, 1}, {2, 4, 2}, {11, 9, 1}, {36, 17, 1}, {36, 18, 18}};
+} Cases[] = {
+    {0, 0, 0},
+    {1, 0, 1},
+    {0, 1, 1},
+    {1, 1, 1},
+    {2, 3, 1},
+    {2, 4, 2},
+    {11, 9, 1},
+    {36, 17, 1},
+    {36, 18, 18},
+    {25, 30, 5},
+    {24, 16, 8},
+    {256, 100, 4}};
 
 template <typename Input1, typename Input2, typename Output>
 constexpr bool test0(int in1, int in2, int out)



More information about the libcxx-commits mailing list