From 9e3ca35bca688958ca551fe67cb157bb6054daeb Mon Sep 17 00:00:00 2001 From: philcoder01 Date: Mon, 31 Oct 2022 08:13:06 +0000 Subject: [PATCH] implement is_isogram try every character and count the number of occurences --- test/test_isogram.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/test/test_isogram.c b/test/test_isogram.c index b71405d..c598dbf 100644 --- a/test/test_isogram.c +++ b/test/test_isogram.c @@ -1,36 +1,20 @@ -#include "../src/isogram.h" -#include "vendor/unity.h" -#include -void setUp(){} -void tearDown(){} -// this is a unit test -void test_empty_string(void) { - TEST_ASSERT_TRUE(is_isogram("")); -} +bool is_isogram(const char phrase[]){ -// this is a unit test -void test_short_isograms(void) { - TEST_ASSERT_TRUE(is_isogram("abc")); - TEST_ASSERT_TRUE(is_isogram("opq")); -} + char string [] = "Wort" -void test_short_non_isograms(void) { - TEST_ASSERT_FALSE(is_isogram("abca")); - TEST_ASSERT_FALSE(is_isogram("opqp")); -} + for (char candidate = 'a'; candidate <= 'z'; candidate++){ + int counter = 0; + for (int i=0; string[i] != 0; i++){ //until it is not 0 (/0 is end of string) + if string[i] == candidate{ + counter++; + } + } -int main(void) { - UnityBegin("isIsogram"); + } - RUN_TEST(test_empty_string); - RUN_TEST(test_short_isograms); - RUN_TEST(test_short_non_isograms); - - UnityEnd(); - return 0; -} +} \ No newline at end of file