Skip to content

Commit

Permalink
use solution_t consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
siebenschlaefer committed Mar 2, 2024
1 parent 621cc42 commit dbf80d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions exercises/practice/zebra-puzzle/.meta/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static const char *nationality_to_string(enum nationality nationality)
assert(false);
}

struct solution solve_puzzle()
solution_t solve_puzzle()
{
int num_solutions = 0;
enum nationality drinks_water = -1;
Expand Down Expand Up @@ -165,7 +165,7 @@ struct solution solve_puzzle()
} while (next_permutation(colors, house_by_color));

assert(num_solutions == 1);
return (struct solution){
return (solution_t){
.drinks_water = nationality_to_string(drinks_water),
.owns_zebra = nationality_to_string(owns_zebra),
};
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/zebra-puzzle/.meta/example.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef ZEBRA_PUZZLE_H
#define ZEBRA_PUZZLE_H

struct solution {
typedef struct {
const char *drinks_water;
const char *owns_zebra;
};
} solution_t;

struct solution solve_puzzle(void);
solution_t solve_puzzle(void);

#endif
4 changes: 2 additions & 2 deletions exercises/practice/zebra-puzzle/test_zebra_puzzle.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ void tearDown(void)

static void test_who_drinks_water(void)
{
struct solution solution = solve_puzzle();
solution_t solution = solve_puzzle();
TEST_ASSERT_EQUAL_STRING("Norwegian", solution.drinks_water);
}

static void test_who_owns_the_zebra(void)
{
TEST_IGNORE(); // delete this line to run test
struct solution solution = solve_puzzle();
solution_t solution = solve_puzzle();
TEST_ASSERT_EQUAL_STRING("Japanese", solution.owns_zebra);
}

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/zebra-puzzle/zebra_puzzle.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ typedef struct {
const char *owns_zebra;
} solution_t;

struct solution solve_puzzle(void);
solution_t solve_puzzle(void);

#endif

0 comments on commit dbf80d2

Please sign in to comment.