TDD in C - Recently Used List Kata

Olve Maudal
Olve MaudalSoftware Developer at Software Developer
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
1 of 269

Recommended

Modern C++ Explained: Move Semantics (Feb 2018) by
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Olve Maudal
8.1K views257 slides
Deep C by
Deep CDeep C
Deep COlve Maudal
871.5K views445 slides
Solid C++ by Example by
Solid C++ by ExampleSolid C++ by Example
Solid C++ by ExampleOlve Maudal
20.4K views204 slides
Insecure coding in C (and C++) by
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)Olve Maudal
22.1K views357 slides
Top C Language Interview Questions and Answer by
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerVineet Kumar Saini
29.7K views48 slides
C++ idioms by example (Nov 2008) by
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
5.5K views78 slides

More Related Content

What's hot

File in c by
File in cFile in c
File in cPrabhu Govind
1.9K views10 slides
88 c-programs by
88 c-programs88 c-programs
88 c-programsLeandro Schenone
954 views296 slides
Chapter 4 : Balagurusamy Programming ANSI in C by
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CBUBT
7.4K views20 slides
Static typing vs dynamic typing languages by
Static typing vs dynamic typing languagesStatic typing vs dynamic typing languages
Static typing vs dynamic typing languagesJawad Khan
479 views12 slides
Chapter 5 Balagurusamy Programming ANSI in c by
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
10.9K views36 slides
Practical write a c program to reverse a given number by
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
9.9K views98 slides

What's hot(20)

Chapter 4 : Balagurusamy Programming ANSI in C by BUBT
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
BUBT7.4K views
Static typing vs dynamic typing languages by Jawad Khan
Static typing vs dynamic typing languagesStatic typing vs dynamic typing languages
Static typing vs dynamic typing languages
Jawad Khan479 views
Chapter 5 Balagurusamy Programming ANSI in c by BUBT
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
BUBT10.9K views
Practical write a c program to reverse a given number by Mainak Sasmal
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal9.9K views
Input output statement in C by Muthuganesh S
Input output statement in CInput output statement in C
Input output statement in C
Muthuganesh S944 views
Introduction to C Programming by Aniket Patne
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Aniket Patne1.4K views
arrays and pointers by Samiksha Pun
arrays and pointersarrays and pointers
arrays and pointers
Samiksha Pun3.2K views
C decision making and looping. by Haard Shah
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah5K views
Conditional Statement in C Language by Shaina Arora
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
Shaina Arora11.9K views
Input and output in C++ by Nilesh Dalvi
Input and output in C++Input and output in C++
Input and output in C++
Nilesh Dalvi7.3K views
Chapter 6 Balagurusamy Programming ANSI in c by BUBT
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
BUBT8.5K views
How to execute a C program by Leela Koneru
How to execute a C  program How to execute a C  program
How to execute a C program
Leela Koneru1.9K views
C, C++ Interview Questions Part - 1 by ReKruiTIn.com
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
ReKruiTIn.com16.8K views

Viewers also liked

How A Compiler Works: GNU Toolchain by
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainNational Cheng Kung University
50.2K views86 slides
C++11 by
C++11C++11
C++11Andrey Dankevich
19.5K views72 slides
Singleton is not_the_only_pattern by
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_patternSeb Rose
2.6K views13 slides
Interpreter, Compiler, JIT from scratch by
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchNational Cheng Kung University
11.9K views62 slides
Introdunction to Network Management Protocols - SNMP & TR-069 by
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069William Lee
8.4K views22 slides
Stock exchange simple ppt by
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple pptAvinash Varun
447K views26 slides

Viewers also liked(20)

Singleton is not_the_only_pattern by Seb Rose
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_pattern
Seb Rose2.6K views
Introdunction to Network Management Protocols - SNMP & TR-069 by William Lee
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069
William Lee8.4K views
Stock exchange simple ppt by Avinash Varun
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple ppt
Avinash Varun447K views
iOS 6 Exploitation 280 days later by Wang Hao Lee
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days later
Wang Hao Lee1.8K views
Data structures & algorithms lecture 3 by Poojith Chowdhary
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
Poojith Chowdhary3.5K views
Escape sequence in c part 1 by Innovative
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1
Innovative713 views
358 33 powerpoint-slides_8-linked-lists_chapter-8 by sumitbardhan
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
sumitbardhan3.8K views
Cygwin Install How-To (Chinese) by William Lee
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
William Lee977 views
Re-identification of Anomized CDR datasets using Social networlk Data by Alket Cecaj
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
Alket Cecaj555 views
Timing over packet demarcation by Nir Cohen
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcation
Nir Cohen1.9K views

Similar to TDD in C - Recently Used List Kata

Python introduction by
Python introductionPython introduction
Python introductionleela rani
137 views44 slides
Advanced perl finer points ,pack&amp;unpack,eval,files by
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
536 views10 slides
Merge radix-sort-algorithm by
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithmRendell Inocencio
52 views38 slides
Merge radix-sort-algorithm by
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithmRendell Inocencio
224 views38 slides
Please answer question only where it states -add code above this line.docx by
Please answer question only where it states -add code above this line.docxPlease answer question only where it states -add code above this line.docx
Please answer question only where it states -add code above this line.docxcgraciela1
3 views1 slide
CBSE Class 12 Computer practical Python Programs and MYSQL by
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
62.3K views31 slides

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

Python introduction by leela rani
Python introductionPython introduction
Python introduction
leela rani137 views
Advanced perl finer points ,pack&amp;unpack,eval,files by Shankar D
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
Shankar D536 views
Please answer question only where it states -add code above this line.docx by cgraciela1
Please answer question only where it states -add code above this line.docxPlease answer question only where it states -add code above this line.docx
Please answer question only where it states -add code above this line.docx
cgraciela13 views
CBSE Class 12 Computer practical Python Programs and MYSQL by Rishabh-Rawat
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-Rawat62.3K views
Array assignment by Ahmad Kamal
Array assignmentArray assignment
Array assignment
Ahmad Kamal1.3K views
Data Structure In C# by Shahzad
Data Structure In C#Data Structure In C#
Data Structure In C#
Shahzad 28K views
Python - Data Collection by JoseTanJr
Python - Data CollectionPython - Data Collection
Python - Data Collection
JoseTanJr37 views
computer notes - Data Structures - 35 by ecomputernotes
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
ecomputernotes11 views
List,tuple,dictionary by nitamhaske
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske4.7K views
Programming in Python by Tiji Thomas
Programming in Python Programming in Python
Programming in Python
Tiji Thomas1.1K views

Recently uploaded

Fleet Management Software in India by
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India Fleetable
11 views1 slide
Unleash The Monkeys by
Unleash The MonkeysUnleash The Monkeys
Unleash The MonkeysJacob Duijzer
8 views28 slides
SAP FOR TYRE INDUSTRY.pdf by
SAP FOR TYRE INDUSTRY.pdfSAP FOR TYRE INDUSTRY.pdf
SAP FOR TYRE INDUSTRY.pdfVirendra Rai, PMP
24 views3 slides
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...Deltares
12 views24 slides
WebAssembly by
WebAssemblyWebAssembly
WebAssemblyJens Siebert
51 views18 slides
Sprint 226 by
Sprint 226Sprint 226
Sprint 226ManageIQ
5 views18 slides

Recently uploaded(20)

Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares12 views
Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ5 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert21 views
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft... by Deltares
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
Deltares7 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana10 views
Headless JS UG Presentation.pptx by Jack Spektor
Headless JS UG Presentation.pptxHeadless JS UG Presentation.pptx
Headless JS UG Presentation.pptx
Jack Spektor8 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492122 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller40 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8712 views
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... by Deltares
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
Deltares9 views

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> ...