Source

Sum “A+B” - CodeAbbey

My solution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>

#include "../lib/unity/src/unity.h" // throwtheswitch.org


int sum(int a, int b) {
    return a + b;
}


void test_mytest() {
    TEST_ASSERT_EQUAL(sum(0, 0), 0);
    TEST_ASSERT_EQUAL(sum(0, 1), 1);
    TEST_ASSERT_EQUAL(sum(-1, 0), -1);
}


void test_provided() {
    TEST_ASSERT_EQUAL(sum(3, 5), 8);
    TEST_ASSERT_EQUAL(sum(4077, 14199), 18276);
}


int run_tests(void) {
    UNITY_BEGIN();
    RUN_TEST(test_mytest);
    RUN_TEST(test_provided);
    return UNITY_END();
}


int main(void) {
    run_tests();

    // Challenge input.
    int a, b;
    if (scanf("%d %d", &a, &b) != EOF) {
        printf("%d", sum(a, b));
    }    
    return 0;
}