From ba3c0319ed3ef6edfb6df4b6a496c639aa6d19f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qu=E1=BB=91c=20Th=C3=A1i=20V=C5=A9?= Date: Thu, 9 Jun 2022 13:50:16 +0700 Subject: [PATCH] Add tests for sum of digits (#3083) --- .../thealgorithms/maths/SumOfDigitsTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/com/thealgorithms/maths/SumOfDigitsTest.java diff --git a/src/test/java/com/thealgorithms/maths/SumOfDigitsTest.java b/src/test/java/com/thealgorithms/maths/SumOfDigitsTest.java new file mode 100644 index 00000000..116a87f5 --- /dev/null +++ b/src/test/java/com/thealgorithms/maths/SumOfDigitsTest.java @@ -0,0 +1,25 @@ +package com.thealgorithms.maths; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author SirFixalot16 + * @since 01/06/22 + */ +public class SumOfDigitsTest { + @Test + void isSumOf2Digits() { + SumOfDigits sum = new SumOfDigits(); + assertEquals(11, sum.sumOfDigits(56)); + } + void isSumOf3Digits() { + SumOfDigits sum = new SumOfDigits(); + assertEquals(12, sum.sumOfDigits(192)); + } + void isSumOf4Digits() { + SumOfDigits sum = new SumOfDigits(); + assertEquals(25, sum.sumOfDigits(8962)); + } +}