SlideShare a Scribd company logo
1 of 269
Download to read offline
TDD in C
Illustrated by the Recently-Used-List kata
Olve Maudal
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt <empty> <empty> <empty> <empty>
Source: cyber-dojo.org
README.txt <empty> <empty> <empty> <empty>
README.txt <empty> <empty> <empty> <empty>
README.txt rul_tests.c <empty> <empty> <empty>
README.txt rul_tests.c <empty> <empty> <empty>
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
cc rul_tests.c && ./a.out
All tests passed
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
cc rul_tests.c && ./a.out
a.out: rul_tests.c:6: main: Assertion `3 == 4' failed.
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
cc rul_tests.c && ./a.out
a.out: rul_tests.c:6: main: Assertion `3 == 4' failed.
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 4);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
cc rul_tests.c && ./a.out
All tests passed
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt <empty> <empty> <empty> <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt <empty> <empty> <empty> <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt <empty> <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
assert(3 == 3);
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
cc rul_tests.c && ./a.out
a.out: rul_tests.c:6: test_list_is_initially_empty: Assertion `3 == 4' failed.
TEST
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
cc rul_tests.c && ./a.out
All tests passed
TEST
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(3 == 3);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert( );
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert( );
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
cc rul_tests.c && ./a.out
rul_tests.c:1:17: fatal error: rul.h: No such file or directory
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c <empty> <empty> <empty>
cc rul_tests.c && ./a.out
rul_tests.c:1:17: fatal error: rul.h: No such file or directory
TEST
README.txt rul_tests.c <empty> <empty> <empty>
README.txt rul_tests.c rul.h <empty> <empty>
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
TEST
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c && ./a.out
rul_tests.c:(.text+0xa): undefined reference to `rul_size'
TEST
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c && ./a.out
rul_tests.c:(.text+0xa): undefined reference to `rul_size'
TEST
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c && ./a.out
rul_tests.c:(.text+0xa): undefined reference to `rul_size'
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c rul.c && ./a.out
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c rul.c && ./a.out
TEST
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c rul.c && ./a.out
cc: error: rul.c: No such file or directory
TEST
README.txt rul_tests.c rul.h <empty> <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
cc rul_tests.c rul.c && ./a.out
cc: error: rul.c: No such file or directory
TEST
README.txt rul_tests.c rul.h <empty> <empty>
README.txt rul_tests.c rul.h rul.c <empty>
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return ;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return ;
}
?
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 42;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 42;
}
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 42;
}
cc rul_tests.c rul.c && ./a.out
test_list_is_initially_empty: Assertion `rul_size() == 0' failed.
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 42;
}
cc rul_tests.c rul.c && ./a.out
test_list_is_initially_empty: Assertion `rul_size() == 0' failed.
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 0;
}
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size() == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
size_t rul_size(void);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(void)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul * rul = NULL;
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return NULL;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return NULL;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return NULL;
}
size_t rul_size(const struct rul * rul)
{
return 0;
} TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return NULL;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
test_list_is_initially_empty: Assertion `rul == &myrul' failed.
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return NULL;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
test_list_is_initially_empty: Assertion `rul == &myrul' failed.
TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
} TEST
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
All tests passed
TEST
#include "rul.h"
#include <assert.h>
#include <stdio.h>
static void test_list_is_initially_empty(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
assert(rul == &myrul);
assert(rul_size(rul) == 0);
}
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
test_size_of_list_increases_as_we_add_unique_items: Assertion `3 == 4' failed.
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
assert(3 == 4);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
rul_tests.c:(.text+0x92): undefined reference to `rul_add'
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
cc rul_tests.c rul.c && ./a.out
rul_tests.c:(.text+0x92): undefined reference to `rul_add'
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
void rul_add(struct rul * rul, const char * num)
{
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
void rul_add(struct rul * rul, const char * num)
{
}
cc rul_tests.c rul.c && ./a.out
a.out: rul_tests.c:19: test_size_of_list_increases_as_we_add_unique_items:
Assertion `rul_size(rul) == 1' failed.
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return 0;
}
void rul_add(struct rul * rul, const char * num)
{
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
rul_add(rul, "1001");
assert(rul_size(rul) == 2);
rul_add(rul, "1002");
rul_add(rul, "1003");
rul_add(rul, "1004");
assert(rul_size(rul) == 5);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
rul_add(rul, "1001");
assert(rul_size(rul) == 2);
rul_add(rul, "1002");
rul_add(rul, "1003");
rul_add(rul, "1004");
assert(rul_size(rul) == 5);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
rul_add(rul, "1001");
assert(rul_size(rul) == 2);
rul_add(rul, "1002");
rul_add(rul, "1003");
rul_add(rul, "1004");
assert(rul_size(rul) == 5);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_size_of_list_increases_as_we_add_unique_items(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(rul_size(rul) == 1);
rul_add(rul, "1001");
assert(rul_size(rul) == 2);
rul_add(rul, "1002");
rul_add(rul, "1003");
rul_add(rul, "1004");
assert(rul_size(rul) == 5);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "";
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "";
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "";
}
cc rul_tests.c rul.c && ./a.out
rul_tests.c:34: test_indexing_into_the_list:
Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "";
}
?
cc rul_tests.c rul.c && ./a.out
rul_tests.c:34: test_indexing_into_the_list:
Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
cc rul_tests.c rul.c && ./a.out
rul_tests.c:34: test_indexing_into_the_list:
Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
#include "rul.h"
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
rul_tests.c:36: test_indexing_into_the_list:
Assertion `strcmp(rul_get(rul, 0), "1001") == 0' failed.
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
struct rul {
size_t n_numbers;
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
#define MAX_NUMLEN 15
#define MAX_NUMBERS 10
struct rul {
size_t n_numbers;
char numbers[MAX_NUMBERS][MAX_NUMLEN+1];
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
#define MAX_NUMLEN 15
#define MAX_NUMBERS 10
struct rul {
size_t n_numbers;
char numbers[MAX_NUMBERS][MAX_NUMLEN+1];
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
#ifndef UTILS_RUL_H_INCLUDED
#define UTILS_RUL_H_INCLUDED
#include <stddef.h>
#define MAX_NUMLEN 15
#define MAX_NUMBERS 10
struct rul {
size_t n_numbers;
char numbers[MAX_NUMBERS][MAX_NUMLEN+1];
};
struct rul * rul_init(struct rul * rul);
size_t rul_size(const struct rul * rul);
void rul_add(struct rul * rul, const char * num);
const char * rul_get(const struct rul * rul, size_t index);
#endif
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
cc rul_tests.c rul.c && ./a.out
All tests passed
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return "1000";
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return rul->numbers[0];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return rul->numbers[0];
}
cc rul_tests.c rul.c && ./a.out
All tests passed
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
// rul_add(rul, "1001");
// assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
assert(strcmp(rul_get(rul, 1), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
rul_tests.c: test_indexing_into_the_list:
Assertion `strcmp(rul_get(rul, 1), "1000") == 0' failed.
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return rul->numbers[0];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
strcpy(rul->numbers[0], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
return rul->numbers[0];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
return;
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
return;
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
struct rul * rul_init(struct rul * rul)
{
rul->n_numbers = 0;
return rul;
}
size_t rul_size(const struct rul * rul)
{
return rul->n_numbers;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
return;
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
cc rul_tests.c rul.c && ./a.out
All tests passed
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
assert(strcmp(rul_get(rul, 1), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
assert(strcmp(rul_get(rul, 1), "1000") == 0);
rul_add(rul, "1002");
rul_add(rul, "1003");
assert(strcmp(rul_get(rul, 0), "1003") == 0);
assert(strcmp(rul_get(rul, 1), "1002") == 0);
assert(strcmp(rul_get(rul, 2), "1001") == 0);
assert(strcmp(rul_get(rul, 3), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_indexing_into_the_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
assert(strcmp(rul_get(rul, 0), "1000") == 0);
rul_add(rul, "1001");
assert(strcmp(rul_get(rul, 0), "1001") == 0);
assert(strcmp(rul_get(rul, 1), "1000") == 0);
rul_add(rul, "1002");
rul_add(rul, "1003");
assert(strcmp(rul_get(rul, 0), "1003") == 0);
assert(strcmp(rul_get(rul, 1), "1002") == 0);
assert(strcmp(rul_get(rul, 2), "1001") == 0);
assert(strcmp(rul_get(rul, 3), "1000") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
All tests passed
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_adding_unique_items_to_full_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
char num[MAX_NUMLEN+1];
for (int i = 0; i < MAX_NUMBERS; i++) {
sprintf(num, "10%02d", i);
rul_add(rul, num);
}
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0);
rul_add(rul, "1234");
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, 0), "1234") == 0);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_adding_unique_items_to_full_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
char num[MAX_NUMLEN+1];
for (int i = 0; i < MAX_NUMBERS; i++) {
sprintf(num, "10%02d", i);
rul_add(rul, num);
}
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0);
rul_add(rul, "1234");
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, 0), "1234") == 0);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
test_adding_unique_items_to_full_list:
Assertion `strcmp(rul_get(rul, 0), "1234") == 0' failed.
static void test_adding_unique_items_to_full_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
char num[MAX_NUMLEN+1];
for (int i = 0; i < MAX_NUMBERS; i++) {
sprintf(num, "10%02d", i);
rul_add(rul, num);
}
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0);
rul_add(rul, "1234");
assert(rul_size(rul) == MAX_NUMBERS);
assert(strcmp(rul_get(rul, 0), "1234") == 0);
assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
cc rul_tests.c rul.c && ./a.out
test_adding_unique_items_to_full_list:
Assertion `strcmp(rul_get(rul, 0), "1234") == 0' failed.
README.txt rul_tests.c rul.h rul.c <empty>
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
return;
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
return;
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
remove_oldest_number(rul);
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
static void remove_oldest_number(struct rul * rul)
{
for (size_t i = 0; i < rul->n_numbers - 1; i++)
strcpy(rul->numbers[i], rul->numbers[i+1]);
rul->n_numbers--;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
remove_oldest_number(rul);
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
README.txt rul_tests.c rul.h rul.c <empty>
static void remove_oldest_number(struct rul * rul)
{
for (size_t i = 0; i < rul->n_numbers - 1; i++)
strcpy(rul->numbers[i], rul->numbers[i+1]);
rul->n_numbers--;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
remove_oldest_number(rul);
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
cc rul_tests.c rul.c && ./a.out
All tests passed
README.txt rul_tests.c rul.h rul.c <empty>
static void remove_oldest_number(struct rul * rul)
{
for (size_t i = 0; i < rul->n_numbers - 1; i++)
strcpy(rul->numbers[i], rul->numbers[i+1]);
rul->n_numbers--;
}
void rul_add(struct rul * rul, const char * num)
{
if (strlen(num) > MAX_NUMLEN)
return;
if (rul->n_numbers == MAX_NUMBERS)
remove_oldest_number(rul);
strcpy(rul->numbers[rul->n_numbers], num);
rul->n_numbers++;
}
const char * rul_get(const struct rul * rul, size_t index)
{
if (index + 1 > rul->n_numbers)
return "";
return rul->numbers[rul->n_numbers - (index + 1)];
}
...
cc rul_tests.c rul.c && ./a.out
All tests passed
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
Develop a recently-used-list module for holding a limited set of
unique phone numbers in a Last-In-First-Out order.
Initially, you may assume that numbers added to the list are no longer
than 15 digits. You may also assume that the capacity of the list is
10 items. (Imagine that this code is to be used to show a list of the
most recently used phone numbers in a very simple cordless phone.)
o) A recently-used-list is initially empty. As you add unique numbers,
the list grows, until capacity is reached.
o) Numbers in the list can be looked up by index. The zeroth element
is the most recently used item.
o) Numbers in the list are unique. If you add a number that already
exists, the number is moved to the zeroth element in the list.
o) When adding a unique number to a full list, the oldest number is
dropped to make room for the new entry.
README.txt rul_tests.c rul.h rul.c <empty>
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
test_adding_existing_numbers_to_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
static void test_adding_existing_numbers_to_list(void)
{
struct rul myrul;
struct rul * rul = rul_init(&myrul);
rul_add(rul, "1000");
rul_add(rul, "1001");
rul_add(rul, "1002");
rul_add(rul, "1003");
assert(rul_size(rul) == 4);
rul_add(rul, "1002");
assert(rul_size(rul) == 4);
assert(strcmp(rul_get(rul, 0), "1002") == 0);
}
int main(void)
{
test_list_is_initially_empty();
test_size_of_list_increases_as_we_add_unique_items();
test_indexing_into_the_list();
test_adding_unique_items_to_full_list();
test_adding_existing_numbers_to_list();
printf("All tests passedn");
}
README.txt rul_tests.c rul.h rul.c <empty>
...
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata
TDD in C - Recently Used List Kata

More Related Content

What's hot

Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Olve Maudal
 
OOP in C++
OOP in C++OOP in C++
OOP in C++ppd1961
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」Tomoaki Shimizu
 
Deep C Programming
Deep C ProgrammingDeep C Programming
Deep C ProgrammingWang Hao Lee
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdfchoconyeuquy
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesSreedhar Chowdam
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 

What's hot (20)

Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
 
C function
C functionC function
C function
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Deep C Programming
Deep C ProgrammingDeep C Programming
Deep C Programming
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
C programming
C programmingC programming
C programming
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Smart Pointers in C++
Smart Pointers in C++Smart Pointers in C++
Smart Pointers in C++
 
C++11
C++11C++11
C++11
 

Viewers also liked

Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_patternSeb Rose
 
Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069William Lee
 
Stock exchange simple ppt
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple pptAvinash Varun
 
iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days laterWang Hao Lee
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Poojith Chowdhary
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1Innovative
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8sumitbardhan
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)William Lee
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataAlket Cecaj
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcationNir Cohen
 
Hello world在那邊?背景說明
Hello world在那邊?背景說明Hello world在那邊?背景說明
Hello world在那邊?背景說明Wen Liao
 
03 the c language
03 the c language03 the c language
03 the c languagearafatmirza
 

Viewers also liked (20)

Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_pattern
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069
 
Stock exchange simple ppt
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple ppt
 
iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days later
 
Dconf2015 d2 t4
Dconf2015 d2 t4Dconf2015 d2 t4
Dconf2015 d2 t4
 
Linked lists
Linked listsLinked lists
Linked lists
 
C Standards: main()
C Standards: main()C Standards: main()
C Standards: main()
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk Data
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcation
 
Hello world在那邊?背景說明
Hello world在那邊?背景說明Hello world在那邊?背景說明
Hello world在那邊?背景說明
 
C programming
C programmingC programming
C programming
 
03 the c language
03 the c language03 the c language
03 the c language
 

Similar to TDD in C - Recently Used List Kata

Python introduction
Python introductionPython introduction
Python introductionleela rani
 
Advanced perl finer points ,pack&amp;unpack,eval,files
Advanced perl   finer points ,pack&amp;unpack,eval,filesAdvanced perl   finer points ,pack&amp;unpack,eval,files
Advanced perl finer points ,pack&amp;unpack,eval,filesShankar D
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL Rishabh-Rawat
 
Array assignment
Array assignmentArray assignment
Array assignmentAhmad Kamal
 
Algorithms notes tutorials duniya
Algorithms notes   tutorials duniyaAlgorithms notes   tutorials duniya
Algorithms notes tutorials duniyaTutorialsDuniya.com
 
You are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfarpaqindia
 
I need help with this program for java.The program you are given t.pdf
I need help with this program for java.The program you are given t.pdfI need help with this program for java.The program you are given t.pdf
I need help with this program for java.The program you are given t.pdffonecomp
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#Shahzad
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked listVivek Bhargav
 
Python - Data Collection
Python - Data CollectionPython - Data Collection
Python - Data CollectionJoseTanJr
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfankit11134
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxadihartanto7
 

Similar to TDD in C - Recently Used List Kata (20)

Python introduction
Python introductionPython introduction
Python introduction
 
Advanced perl finer points ,pack&amp;unpack,eval,files
Advanced perl   finer points ,pack&amp;unpack,eval,filesAdvanced perl   finer points ,pack&amp;unpack,eval,files
Advanced perl finer points ,pack&amp;unpack,eval,files
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
 
Array assignment
Array assignmentArray assignment
Array assignment
 
Algorithms notes tutorials duniya
Algorithms notes   tutorials duniyaAlgorithms notes   tutorials duniya
Algorithms notes tutorials duniya
 
Word games in c
Word games in cWord games in c
Word games in c
 
You are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdf
 
I need help with this program for java.The program you are given t.pdf
I need help with this program for java.The program you are given t.pdfI need help with this program for java.The program you are given t.pdf
I need help with this program for java.The program you are given t.pdf
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
stack.ppt
stack.pptstack.ppt
stack.ppt
 
Day2
Day2Day2
Day2
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Python Workshop
Python  Workshop Python  Workshop
Python Workshop
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
Python - Data Collection
Python - Data CollectionPython - Data Collection
Python - Data Collection
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
 
Arrays
ArraysArrays
Arrays
 

Recently uploaded

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Recently uploaded (20)

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 

TDD in C - Recently Used List Kata

  • 1. TDD in C Illustrated by the Recently-Used-List kata Olve Maudal
  • 2. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt <empty> <empty> <empty> <empty> Source: cyber-dojo.org
  • 3. README.txt <empty> <empty> <empty> <empty>
  • 4. README.txt <empty> <empty> <empty> <empty>
  • 8. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 9. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 10. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 11. #include <stdio.h> int main(void) { printf("All tests passedn"); } cc rul_tests.c && ./a.out All tests passed README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 12. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 13. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 14. #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 15. #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 16. #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 17. #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 18. #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 19. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 20. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 21. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 22. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } cc rul_tests.c && ./a.out a.out: rul_tests.c:6: main: Assertion `3 == 4' failed. README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 23. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } cc rul_tests.c && ./a.out a.out: rul_tests.c:6: main: Assertion `3 == 4' failed. README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 24. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 4); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 25. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 26. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 27. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 28. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } cc rul_tests.c && ./a.out All tests passed README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 29. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 30. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt <empty> <empty> <empty> <empty>
  • 31. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt <empty> <empty> <empty> <empty>
  • 32. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt <empty> <empty> <empty> <empty>
  • 33. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 34. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 35. #include <assert.h> #include <stdio.h> int main(void) { assert(3 == 3); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 36. #include <assert.h> #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 37. #include <assert.h> #include <stdio.h> int main(void) { printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 38. #include <assert.h> #include <stdio.h> int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 39. #include <assert.h> #include <stdio.h> int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 40. #include <assert.h> #include <stdio.h> int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 41. #include <assert.h> #include <stdio.h> int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 42. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 43. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 44. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 45. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> cc rul_tests.c && ./a.out a.out: rul_tests.c:6: test_list_is_initially_empty: Assertion `3 == 4' failed. TEST
  • 46. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 47. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 48. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 49. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 50. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> cc rul_tests.c && ./a.out All tests passed TEST
  • 51. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 52. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 53. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(3 == 3); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 54. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert( ); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 55. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert( ); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 56. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 57. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 58. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 59. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 60. #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 61. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 62. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty>
  • 63. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> TEST
  • 64. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> cc rul_tests.c && ./a.out rul_tests.c:1:17: fatal error: rul.h: No such file or directory TEST
  • 65. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c <empty> <empty> <empty> cc rul_tests.c && ./a.out rul_tests.c:1:17: fatal error: rul.h: No such file or directory TEST
  • 67. README.txt rul_tests.c rul.h <empty> <empty>
  • 68. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif
  • 69. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif
  • 70. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif TEST
  • 71. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c && ./a.out rul_tests.c:(.text+0xa): undefined reference to `rul_size' TEST
  • 72. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c && ./a.out rul_tests.c:(.text+0xa): undefined reference to `rul_size' TEST
  • 73. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c && ./a.out rul_tests.c:(.text+0xa): undefined reference to `rul_size'
  • 74. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c rul.c && ./a.out
  • 75. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c rul.c && ./a.out TEST
  • 76. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c rul.c && ./a.out cc: error: rul.c: No such file or directory TEST
  • 77. README.txt rul_tests.c rul.h <empty> <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif cc rul_tests.c rul.c && ./a.out cc: error: rul.c: No such file or directory TEST
  • 78. README.txt rul_tests.c rul.h <empty> <empty>
  • 80. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return ; }
  • 81. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return ; } ?
  • 82. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 42; }
  • 83. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 42; } TEST
  • 84. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 42; } cc rul_tests.c rul.c && ./a.out test_list_is_initially_empty: Assertion `rul_size() == 0' failed. TEST
  • 85. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 42; } cc rul_tests.c rul.c && ./a.out test_list_is_initially_empty: Assertion `rul_size() == 0' failed. TEST
  • 86. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 0; }
  • 87. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 0; } TEST
  • 88. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 0; } cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 89. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 0; } cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 90. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 91. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> TEST
  • 92. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 93. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 94. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 95. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 96. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size() == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 97. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 98. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 99. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 100. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 101. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 102. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> size_t rul_size(void); #endif
  • 103. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; size_t rul_size(const struct rul * rul); #endif
  • 104. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; size_t rul_size(const struct rul * rul); #endif
  • 105. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(void) { return 0; }
  • 106. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; }
  • 107. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; } TEST
  • 108. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; } cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 109. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; } cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 110. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 111. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 112. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul * rul = NULL; assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 113. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 114. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 115. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 116. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; size_t rul_size(const struct rul * rul); #endif
  • 117. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); #endif
  • 118. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); #endif
  • 119. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; }
  • 120. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" size_t rul_size(const struct rul * rul) { return 0; }
  • 121. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return NULL; } size_t rul_size(const struct rul * rul) { return 0; }
  • 122. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return NULL; } size_t rul_size(const struct rul * rul) { return 0; }
  • 123. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return NULL; } size_t rul_size(const struct rul * rul) { return 0; } TEST
  • 124. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return NULL; } size_t rul_size(const struct rul * rul) { return 0; } cc rul_tests.c rul.c && ./a.out test_list_is_initially_empty: Assertion `rul == &myrul' failed. TEST
  • 125. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return NULL; } size_t rul_size(const struct rul * rul) { return 0; } cc rul_tests.c rul.c && ./a.out test_list_is_initially_empty: Assertion `rul == &myrul' failed. TEST
  • 126. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; }
  • 127. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; }
  • 128. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; } TEST
  • 129. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; } cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 130. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 131. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> TEST
  • 132. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 133. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 134. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 135. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 136. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 137. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 138. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 139. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 140. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> TEST
  • 141. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out All tests passed TEST
  • 142. #include "rul.h" #include <assert.h> #include <stdio.h> static void test_list_is_initially_empty(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); assert(rul == &myrul); assert(rul_size(rul) == 0); } int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 143. ... int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 144. ... int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 145. ... int main(void) { test_list_is_initially_empty(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 147. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 148. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out test_size_of_list_increases_as_we_add_unique_items: Assertion `3 == 4' failed.
  • 149. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 150. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { assert(3 == 4); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 151. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty>
  • 152. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out rul_tests.c:(.text+0x92): undefined reference to `rul_add'
  • 153. ... static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> cc rul_tests.c rul.c && ./a.out rul_tests.c:(.text+0x92): undefined reference to `rul_add'
  • 154. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); #endif
  • 155. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 156. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 157. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; }
  • 158. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; } void rul_add(struct rul * rul, const char * num) { }
  • 159. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; } void rul_add(struct rul * rul, const char * num) { } cc rul_tests.c rul.c && ./a.out a.out: rul_tests.c:19: test_size_of_list_increases_as_we_add_unique_items: Assertion `rul_size(rul) == 1' failed.
  • 160. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return 0; } void rul_add(struct rul * rul, const char * num) { }
  • 161. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { }
  • 162. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { }
  • 163. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; }
  • 164. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; }
  • 165. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; }
  • 166. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul {}; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 167. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 168. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 169. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 170. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif cc rul_tests.c rul.c && ./a.out All tests passed
  • 171. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif cc rul_tests.c rul.c && ./a.out All tests passed
  • 172. static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 173. static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); rul_add(rul, "1001"); assert(rul_size(rul) == 2); rul_add(rul, "1002"); rul_add(rul, "1003"); rul_add(rul, "1004"); assert(rul_size(rul) == 5); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 174. static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); rul_add(rul, "1001"); assert(rul_size(rul) == 2); rul_add(rul, "1002"); rul_add(rul, "1003"); rul_add(rul, "1004"); assert(rul_size(rul) == 5); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 175. static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); rul_add(rul, "1001"); assert(rul_size(rul) == 2); rul_add(rul, "1002"); rul_add(rul, "1003"); rul_add(rul, "1004"); assert(rul_size(rul) == 5); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 176. static void test_size_of_list_increases_as_we_add_unique_items(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(rul_size(rul) == 1); rul_add(rul, "1001"); assert(rul_size(rul) == 2); rul_add(rul, "1002"); rul_add(rul, "1003"); rul_add(rul, "1004"); assert(rul_size(rul) == 5); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 177. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 178. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 179. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 180. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 183. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 184. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 185. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 186. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); #endif
  • 187. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif
  • 188. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif
  • 189. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; }
  • 190. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return ""; }
  • 191. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return ""; }
  • 192. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return ""; } cc rul_tests.c rul.c && ./a.out rul_tests.c:34: test_indexing_into_the_list: Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
  • 193. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return ""; } ? cc rul_tests.c rul.c && ./a.out rul_tests.c:34: test_indexing_into_the_list: Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
  • 194. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } cc rul_tests.c rul.c && ./a.out rul_tests.c:34: test_indexing_into_the_list: Assertion `strcmp(rul_get(rul, 0), "1000") == 0' failed.
  • 195. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; }
  • 196. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } cc rul_tests.c rul.c && ./a.out All tests passed
  • 197. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } cc rul_tests.c rul.c && ./a.out All tests passed
  • 198. README.txt rul_tests.c rul.h rul.c <empty> #include "rul.h" struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } cc rul_tests.c rul.c && ./a.out All tests passed
  • 199. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 200. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 201. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 202. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out rul_tests.c:36: test_indexing_into_the_list: Assertion `strcmp(rul_get(rul, 0), "1001") == 0' failed.
  • 203. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 204. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 205. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 206. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 207. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 208. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> struct rul { size_t n_numbers; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif
  • 209. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> #define MAX_NUMLEN 15 #define MAX_NUMBERS 10 struct rul { size_t n_numbers; char numbers[MAX_NUMBERS][MAX_NUMLEN+1]; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif
  • 210. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> #define MAX_NUMLEN 15 #define MAX_NUMBERS 10 struct rul { size_t n_numbers; char numbers[MAX_NUMBERS][MAX_NUMLEN+1]; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif cc rul_tests.c rul.c && ./a.out All tests passed
  • 211. README.txt rul_tests.c rul.h rul.c <empty> #ifndef UTILS_RUL_H_INCLUDED #define UTILS_RUL_H_INCLUDED #include <stddef.h> #define MAX_NUMLEN 15 #define MAX_NUMBERS 10 struct rul { size_t n_numbers; char numbers[MAX_NUMBERS][MAX_NUMLEN+1]; }; struct rul * rul_init(struct rul * rul); size_t rul_size(const struct rul * rul); void rul_add(struct rul * rul, const char * num); const char * rul_get(const struct rul * rul, size_t index); #endif cc rul_tests.c rul.c && ./a.out All tests passed
  • 212. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } ...
  • 213. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } ...
  • 214. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } cc rul_tests.c rul.c && ./a.out All tests passed ...
  • 215. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } ...
  • 216. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return "1000"; } ...
  • 217. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return rul->numbers[0]; } ...
  • 218. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return rul->numbers[0]; } cc rul_tests.c rul.c && ./a.out All tests passed ...
  • 219. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 220. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 221. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); // rul_add(rul, "1001"); // assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 222. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 223. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 224. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 225. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); assert(strcmp(rul_get(rul, 1), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out rul_tests.c: test_indexing_into_the_list: Assertion `strcmp(rul_get(rul, 1), "1000") == 0' failed.
  • 226. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return rul->numbers[0]; } ...
  • 227. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; strcpy(rul->numbers[0], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { return rul->numbers[0]; } ...
  • 228. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) return; strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ...
  • 229. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) return; strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 230. README.txt rul_tests.c rul.h rul.c <empty> struct rul * rul_init(struct rul * rul) { rul->n_numbers = 0; return rul; } size_t rul_size(const struct rul * rul) { return rul->n_numbers; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) return; strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 231. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); assert(strcmp(rul_get(rul, 1), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 232. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); assert(strcmp(rul_get(rul, 1), "1000") == 0); rul_add(rul, "1002"); rul_add(rul, "1003"); assert(strcmp(rul_get(rul, 0), "1003") == 0); assert(strcmp(rul_get(rul, 1), "1002") == 0); assert(strcmp(rul_get(rul, 2), "1001") == 0); assert(strcmp(rul_get(rul, 3), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 233. static void test_indexing_into_the_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); assert(strcmp(rul_get(rul, 0), "1000") == 0); rul_add(rul, "1001"); assert(strcmp(rul_get(rul, 0), "1001") == 0); assert(strcmp(rul_get(rul, 1), "1000") == 0); rul_add(rul, "1002"); rul_add(rul, "1003"); assert(strcmp(rul_get(rul, 0), "1003") == 0); assert(strcmp(rul_get(rul, 1), "1002") == 0); assert(strcmp(rul_get(rul, 2), "1001") == 0); assert(strcmp(rul_get(rul, 3), "1000") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 234. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 235. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 236. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 237. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 240. static void test_adding_unique_items_to_full_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); char num[MAX_NUMLEN+1]; for (int i = 0; i < MAX_NUMBERS; i++) { sprintf(num, "10%02d", i); rul_add(rul, num); } assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0); rul_add(rul, "1234"); assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, 0), "1234") == 0); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); test_adding_unique_items_to_full_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...
  • 241. static void test_adding_unique_items_to_full_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); char num[MAX_NUMLEN+1]; for (int i = 0; i < MAX_NUMBERS; i++) { sprintf(num, "10%02d", i); rul_add(rul, num); } assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0); rul_add(rul, "1234"); assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, 0), "1234") == 0); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); test_adding_unique_items_to_full_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out test_adding_unique_items_to_full_list: Assertion `strcmp(rul_get(rul, 0), "1234") == 0' failed.
  • 242. static void test_adding_unique_items_to_full_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); char num[MAX_NUMLEN+1]; for (int i = 0; i < MAX_NUMBERS; i++) { sprintf(num, "10%02d", i); rul_add(rul, num); } assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1000") == 0); rul_add(rul, "1234"); assert(rul_size(rul) == MAX_NUMBERS); assert(strcmp(rul_get(rul, 0), "1234") == 0); assert(strcmp(rul_get(rul, MAX_NUMBERS-1), "1001") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); test_adding_unique_items_to_full_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ... cc rul_tests.c rul.c && ./a.out test_adding_unique_items_to_full_list: Assertion `strcmp(rul_get(rul, 0), "1234") == 0' failed.
  • 243. README.txt rul_tests.c rul.h rul.c <empty> void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) return; strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ...
  • 244. README.txt rul_tests.c rul.h rul.c <empty> void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) return; strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ...
  • 245. README.txt rul_tests.c rul.h rul.c <empty> void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) remove_oldest_number(rul); strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ...
  • 246. README.txt rul_tests.c rul.h rul.c <empty> static void remove_oldest_number(struct rul * rul) { for (size_t i = 0; i < rul->n_numbers - 1; i++) strcpy(rul->numbers[i], rul->numbers[i+1]); rul->n_numbers--; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) remove_oldest_number(rul); strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ...
  • 247. README.txt rul_tests.c rul.h rul.c <empty> static void remove_oldest_number(struct rul * rul) { for (size_t i = 0; i < rul->n_numbers - 1; i++) strcpy(rul->numbers[i], rul->numbers[i+1]); rul->n_numbers--; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) remove_oldest_number(rul); strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 248. README.txt rul_tests.c rul.h rul.c <empty> static void remove_oldest_number(struct rul * rul) { for (size_t i = 0; i < rul->n_numbers - 1; i++) strcpy(rul->numbers[i], rul->numbers[i+1]); rul->n_numbers--; } void rul_add(struct rul * rul, const char * num) { if (strlen(num) > MAX_NUMLEN) return; if (rul->n_numbers == MAX_NUMBERS) remove_oldest_number(rul); strcpy(rul->numbers[rul->n_numbers], num); rul->n_numbers++; } const char * rul_get(const struct rul * rul, size_t index) { if (index + 1 > rul->n_numbers) return ""; return rul->numbers[rul->n_numbers - (index + 1)]; } ... cc rul_tests.c rul.c && ./a.out All tests passed
  • 249. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 250. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 251. Develop a recently-used-list module for holding a limited set of unique phone numbers in a Last-In-First-Out order. Initially, you may assume that numbers added to the list are no longer than 15 digits. You may also assume that the capacity of the list is 10 items. (Imagine that this code is to be used to show a list of the most recently used phone numbers in a very simple cordless phone.) o) A recently-used-list is initially empty. As you add unique numbers, the list grows, until capacity is reached. o) Numbers in the list can be looked up by index. The zeroth element is the most recently used item. o) Numbers in the list are unique. If you add a number that already exists, the number is moved to the zeroth element in the list. o) When adding a unique number to a full list, the oldest number is dropped to make room for the new entry. README.txt rul_tests.c rul.h rul.c <empty>
  • 254. static void test_adding_existing_numbers_to_list(void) { struct rul myrul; struct rul * rul = rul_init(&myrul); rul_add(rul, "1000"); rul_add(rul, "1001"); rul_add(rul, "1002"); rul_add(rul, "1003"); assert(rul_size(rul) == 4); rul_add(rul, "1002"); assert(rul_size(rul) == 4); assert(strcmp(rul_get(rul, 0), "1002") == 0); } int main(void) { test_list_is_initially_empty(); test_size_of_list_increases_as_we_add_unique_items(); test_indexing_into_the_list(); test_adding_unique_items_to_full_list(); test_adding_existing_numbers_to_list(); printf("All tests passedn"); } README.txt rul_tests.c rul.h rul.c <empty> ...