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

More Related Content

What's hot

Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)Olve Maudal
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C BUBT
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structureRumman Ansari
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerVineet Kumar Saini
 
An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...Claudio Capobianco
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Decision making and branching in c programming
Decision making and branching in c programmingDecision making and branching in c programming
Decision making and branching in c programmingPriyansh Thakar
 
The Rust Programming Language: an Overview
The Rust Programming Language: an OverviewThe Rust Programming Language: an Overview
The Rust Programming Language: an OverviewRoberto Casadei
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30Chris Ohk
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programmingRodolfo Finochietti
 
Clean code: meaningful Name
Clean code: meaningful NameClean code: meaningful Name
Clean code: meaningful Namenahid035
 

What's hot (20)

Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
pre processor directives in C
pre processor directives in Cpre processor directives in C
pre processor directives in C
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
 
Decision making and branching in c programming
Decision making and branching in c programmingDecision making and branching in c programming
Decision making and branching in c programming
 
Clean code
Clean codeClean code
Clean code
 
The Rust Programming Language: an Overview
The Rust Programming Language: an OverviewThe Rust Programming Language: an Overview
The Rust Programming Language: an Overview
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programming
 
Clean code: meaningful Name
Clean code: meaningful NameClean code: meaningful Name
Clean code: meaningful Name
 
Functions in C
Functions in CFunctions in C
Functions in C
 

Viewers also liked

C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_patternSeb Rose
 
Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069William Lee
 
Stock exchange simple ppt
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple pptAvinash Varun
 
iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days laterWang Hao Lee
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Poojith Chowdhary
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1Innovative
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8sumitbardhan
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)William Lee
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataAlket Cecaj
 

Viewers also liked (20)

C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
C++11
C++11C++11
C++11
 
Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_pattern
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069Introdunction to Network Management Protocols - SNMP & TR-069
Introdunction to Network Management Protocols - SNMP & TR-069
 
Stock exchange simple ppt
Stock exchange simple pptStock exchange simple ppt
Stock exchange simple ppt
 
iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days later
 
Dconf2015 d2 t4
Dconf2015 d2 t4Dconf2015 d2 t4
Dconf2015 d2 t4
 
Linked lists
Linked listsLinked lists
Linked lists
 
C Standards: main()
C Standards: main()C Standards: main()
C Standards: main()
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk Data
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 

Similar to TDD in C - Recently Used List Kata

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

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

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

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 

Recently uploaded (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 

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