mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-23 23:32:45 +00:00
Use a setup and teardown function
This commit is contained in:
parent
bb92162dba
commit
ca7e576266
@ -2,12 +2,26 @@
|
|||||||
|
|
||||||
#include "vm_segment.h"
|
#include "vm_segment.h"
|
||||||
|
|
||||||
|
static vm_segment *segment;
|
||||||
|
static int length = 128;
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup()
|
||||||
|
{
|
||||||
|
segment = vm_segment_create(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
teardown()
|
||||||
|
{
|
||||||
|
vm_segment_free(segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSuite(vm_segment, .init = setup, .fini = teardown);
|
||||||
|
|
||||||
Test(vm_segment, create) {
|
Test(vm_segment, create) {
|
||||||
vm_segment *segment;
|
|
||||||
int length = 128;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
segment = vm_segment_create(length);
|
|
||||||
cr_assert_neq(segment, NULL);
|
cr_assert_neq(segment, NULL);
|
||||||
cr_assert_eq(segment->size, length);
|
cr_assert_eq(segment->size, length);
|
||||||
|
|
||||||
@ -18,43 +32,27 @@ Test(vm_segment, create) {
|
|||||||
cr_assert_eq(segment->read_table[i], NULL);
|
cr_assert_eq(segment->read_table[i], NULL);
|
||||||
cr_assert_eq(segment->write_table[i], NULL);
|
cr_assert_eq(segment->write_table[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_segment_free(segment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(vm_segment, set) {
|
Test(vm_segment, set) {
|
||||||
vm_segment *segment;
|
|
||||||
int length = 128;
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
vm_8bit value = 123;
|
vm_8bit value = 123;
|
||||||
|
|
||||||
segment = vm_segment_create(length);
|
|
||||||
cr_assert_neq(segment, NULL);
|
|
||||||
|
|
||||||
cr_assert_eq(vm_segment_set(segment, index, value), OK);
|
cr_assert_eq(vm_segment_set(segment, index, value), OK);
|
||||||
|
|
||||||
cr_assert_eq(segment->memory[index], value);
|
cr_assert_eq(segment->memory[index], value);
|
||||||
vm_segment_free(segment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(vm_segment, get) {
|
Test(vm_segment, get) {
|
||||||
vm_segment *segment;
|
|
||||||
int length = 128;
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
vm_8bit value = 123;
|
vm_8bit value = 123;
|
||||||
|
|
||||||
segment = vm_segment_create(length);
|
|
||||||
cr_assert_neq(segment, NULL);
|
|
||||||
|
|
||||||
segment->memory[index] = value;
|
segment->memory[index] = value;
|
||||||
cr_assert_eq(vm_segment_get(segment, index), value);
|
cr_assert_eq(vm_segment_get(segment, index), value);
|
||||||
|
|
||||||
vm_segment_free(segment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(vm_segment, copy) {
|
Test(vm_segment, copy) {
|
||||||
vm_segment *src, *dest;
|
vm_segment *src, *dest;
|
||||||
int length = 128;
|
|
||||||
|
|
||||||
src = vm_segment_create(length);
|
src = vm_segment_create(length);
|
||||||
dest = vm_segment_create(length);
|
dest = vm_segment_create(length);
|
||||||
|
Loading…
Reference in New Issue
Block a user