File: engine_test.c

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 62,416 kB
  • sloc: ansic: 192,636; cpp: 14,151; javascript: 9,654; objc: 9,181; java: 3,337; python: 3,333; sh: 1,783; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 126
file content (88 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "csound.h"
#include <stdio.h>
#include <CUnit/Basic.h>

#include "time.h"

int init_suite1(void)
{
    return 0;
}

int clean_suite1(void)
{
    return 0;
}

void test_daemon(void)
{
    CSOUND  *csound;
    csound = csoundCreate(NULL);
    csoundSetIsGraphable(csound, 1);
    csoundSetOption(csound,"-odac");
    csoundSetOption(csound,"--daemon");
    csoundStart(csound);
    csoundSleep(1000);
    /* delete Csound instance */
    csoundStop(csound);
    csoundDestroy(csound);
}

void test_eval_code(void)
{
    CSOUND  *csound;
    MYFLT res;
    csound = csoundCreate(NULL);
    res = csoundEvalCode(csound, "i1 init 1 \n"
			 "print i1 \n"
			 "return i1 \n");
    CU_ASSERT_EQUAL(res, 1.0);
    csoundDestroy(csound);
}

void test_compile_async(void)
{
    CSOUND  *csound;
    csound = csoundCreate(NULL);
    csoundStart(csound);
    csoundCompileOrcAsync(csound, "instr 1\n"
		               "i1 = 1 \n"
		                "print i1 \n"
                                "endin\n"
		                "schedule 1,0,1");
    csoundPerformBuffer(csound);
    csoundDestroy(csound);
}

int main()
{
    CU_pSuite pSuite = NULL;

    /* initialize the CUnit test registry */
    if (CUE_SUCCESS != CU_initialize_registry())
        return CU_get_error();

    /* add a suite to the registry */
    pSuite = CU_add_suite("csound_orc_semantics function tests", init_suite1, clean_suite1);
    if (NULL == pSuite) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* add the tests to the suite */
    if ((NULL == CU_add_test(pSuite, "Test daemon mode", test_daemon))
        || (NULL == CU_add_test(pSuite, "Test evalcode", test_eval_code))
	|| (NULL == CU_add_test(pSuite, "Test compileAsync", test_compile_async)) 
	)
    {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Run all tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    CU_cleanup_registry();
    return CU_get_error();
}