void test_funcOfNAND_given_QUAD_2_INPUT_NAND_and_HIGH_in_both_input_should_return_LOW(void)
{
    Module *NAND;
    int inputType = QUAD_2_INPUT;

    NAND = createdNandModule(inputType);
    (NAND->pin[0]).state = HIGH;
    (NAND->pin[1]).state = HIGH;

    TEST_ASSERT_EQUAL(LOW, funcOfNAND(NAND, NAND->pin[0].pinNumber, inputType));

    destroyModule(NAND);
}
void test_funcOfXOR_given_QUAD_2_INPUT_XOR_and_both_input_are_same_state_should_return_LOW(void)
{
    Module *XOR;
    int inputType = QUAD_2_INPUT;

    XOR = createdXorModule(inputType);
    (XOR->pin[0]).state = LOW;
    (XOR->pin[1]).state = LOW;

    TEST_ASSERT_EQUAL(LOW, funcOfXOR(XOR, XOR->pin[0].pinNumber, inputType));

    destroyModule(XOR);
}
void test_pipeEvent_given_pipe_with_3_module_data_should_register_event_for_all_pipe_data(void)
{
    Module *AND1, *AND2, *OR;
    ModuleAndPin *andData1, *andData2, *orData;
    Pipe *pipe;
    Node *and1RootNode, *and2Node, *orNode;
    int inputType = QUAD_2_INPUT;

    AND1 = createdAndModule(inputType);
    AND2 = createdAndModule(inputType);
    OR = createdOrModule(inputType);
    pipe = createdPipeModule();
    pipe->stateToFire = HIGH;
    andData1 = createdModuleAndPin(AND1, (AND1->pin[0]).pinNumber);
    andData2 = createdModuleAndPin(AND2, (AND2->pin[0]).pinNumber);
    orData = createdModuleAndPin(OR, (OR->pin[1]).pinNumber);

    and1RootNode = createdNewPipeDataNode(andData1);
    and2Node = createdNewPipeDataNode(andData2);
    orNode = createdNewPipeDataNode(orData);
    setNode(and1RootNode, orNode, and2Node, 'b');
    pipe->data = and1RootNode;

    registerEvent_Expect(orData, NULL, ONE_NANO_SEC + OR_PROPAGATION_DELAY);
    registerEvent_Expect(andData2, NULL, ONE_NANO_SEC + AND_PROPAGATION_DELAY);
    registerEvent_Expect(andData1, NULL, ONE_NANO_SEC + AND_PROPAGATION_DELAY);

    pipe->event((void *)pipe, (void *)pipe->data, ONE_NANO_SEC);

    TEST_ASSERT_EQUAL(HIGH, (AND1->pin[0]).state);
    TEST_ASSERT_EQUAL(HIGH, (AND2->pin[0]).state);
    TEST_ASSERT_EQUAL(HIGH, (OR->pin[1]).state);

    destroyModule(OR);
    destroyModule(AND2);
    destroyModule(AND1);
    destroyPipeData(pipe);
}
void test_funcOfNOR_given_TRI_3_INPUT_NOR_and_either_one_input_HIGH_should_return_LOW(void)
{
    Module *NOR;
    int inputType = TRI_3_INPUT;

    NOR = createdNorModule(inputType);
    (NOR->pin[0]).state = LOW;
    (NOR->pin[1]).state = LOW;
    (NOR->pin[2]).state = HIGH;

    TEST_ASSERT_EQUAL(LOW, funcOfNOR(NOR, NOR->pin[0].pinNumber, inputType));

    destroyModule(NOR);
}
void test_funcOfNOR_given_TRI_3_INPUT_NOR_and_LOW_in_all_input_should_return_HIGH(void)
{
    Module *NOR;
    int inputType = TRI_3_INPUT;

    NOR = createdNorModule(inputType);
    (NOR->pin[6]).state = LOW;
    (NOR->pin[7]).state = LOW;
    (NOR->pin[8]).state = LOW;

    TEST_ASSERT_EQUAL(HIGH, funcOfNOR(NOR, NOR->pin[6].pinNumber, inputType));

    destroyModule(NOR);
}
void test_funcOfNAND_given_TRI_3_INPUT_NAND_and_either_one_input_LOW_should_return_HIGH(void)
{
    Module *NAND;
    int inputType = TRI_3_INPUT;

    NAND = createdNandModule(inputType);
    (NAND->pin[0]).state = HIGH;
    (NAND->pin[1]).state = LOW;
    (NAND->pin[2]).state = HIGH;

    TEST_ASSERT_EQUAL(HIGH, funcOfNAND(NAND, NAND->pin[0].pinNumber, inputType));

    destroyModule(NAND);
}
void test_funcOfNAND_given_TRI_3_INPUT_NAND_and_HIGH_in_all_input_should_return_LOW(void)
{
    Module *NAND;
    int inputType = TRI_3_INPUT;

    NAND = createdNandModule(inputType);
    (NAND->pin[6]).state = HIGH;
    (NAND->pin[7]).state = HIGH;
    (NAND->pin[8]).state = HIGH;

    TEST_ASSERT_EQUAL(LOW, funcOfNAND(NAND, NAND->pin[6].pinNumber, inputType));

    destroyModule(NAND);
}
void test_funcOfXOR_given_TRI_3_INPUT_XOR_and_all_input_LOW_should_return_LOW(void)
{
    Module *XOR;
    int inputType = TRI_3_INPUT;

    XOR = createdXorModule(inputType);
    (XOR->pin[0]).state = LOW;
    (XOR->pin[1]).state = LOW;
    (XOR->pin[2]).state = LOW;

    TEST_ASSERT_EQUAL(LOW, funcOfXOR(XOR, XOR->pin[0].pinNumber, inputType));

    destroyModule(XOR);
}
void test_funcOfXOR_given_TRI_3_INPUT_XOR_and_all_input_HIGH_should_return_HIGH(void)
{
    Module *XOR;
    int inputType = TRI_3_INPUT;

    XOR = createdXorModule(inputType);
    (XOR->pin[6]).state = HIGH;
    (XOR->pin[7]).state = HIGH;
    (XOR->pin[8]).state = HIGH;

    TEST_ASSERT_EQUAL(HIGH, funcOfXOR(XOR, XOR->pin[6].pinNumber, inputType));

    destroyModule(XOR);
}
void test_funcOfOR_given_TRI_3_INPUT_OR_and_either_one_input_HIGH_should_return_HIGH(void)
{
    Module *OR;
    int inputType = TRI_3_INPUT;

    OR = createdOrModule(inputType);
    (OR->pin[0]).state = LOW;
    (OR->pin[1]).state = LOW;
    (OR->pin[2]).state = HIGH;

    TEST_ASSERT_EQUAL(HIGH, funcOfOR(OR, OR->pin[0].pinNumber, inputType));

    destroyModule(OR);
}
void test_funcOfOR_given_TRI_3_INPUT_OR_and_LOW_in_all_input_should_return_LOW(void)
{
    Module *OR;
    int inputType = TRI_3_INPUT;

    OR = createdOrModule(inputType);
    (OR->pin[6]).state = LOW;
    (OR->pin[7]).state = LOW;
    (OR->pin[8]).state = LOW;

    TEST_ASSERT_EQUAL(LOW, funcOfOR(OR, OR->pin[6].pinNumber, inputType));

    destroyModule(OR);
}
void test_funcOfAND_given_TRI_3_INPUT_AND_and_HIGH_in_all_input_should_return_HIGH(void)
{
    Module *AND;
    int inputType = TRI_3_INPUT;

    AND = createdAndModule(inputType);
    (AND->pin[6]).state = HIGH;
    (AND->pin[7]).state = HIGH;
    (AND->pin[8]).state = HIGH;

    TEST_ASSERT_EQUAL(HIGH, funcOfAND(AND, AND->pin[6].pinNumber, inputType));

    destroyModule(AND);
}
void test_funcOfAND_given_TRI_3_INPUT_AND_and_either_one_input_LOW_should_return_LOW(void)
{
    Module *AND;
    int inputType = TRI_3_INPUT;

    AND = createdAndModule(inputType);
    (AND->pin[0]).state = HIGH;
    (AND->pin[1]).state = LOW;
    (AND->pin[2]).state = HIGH;

    TEST_ASSERT_EQUAL(LOW, funcOfAND(AND, AND->pin[0].pinNumber, inputType));

    destroyModule(AND);
}
void test_setAnd_given_AND_module_should_set_input_of_AND_module_and_register_event(void)
{
    Module *AND;
    ModuleAndPin *moduleAndPin;
    int inputType = QUAD_2_INPUT;

    AND = createdAndModule(inputType);
    moduleAndPin = createdModuleAndPin(AND, (AND->pin[0]).pinNumber);

    registerEvent_Expect(moduleAndPin, NULL, ONE_NANO_SEC + AND_PROPAGATION_DELAY);

    AND->set((void *)moduleAndPin, HIGH, ONE_NANO_SEC);

    TEST_ASSERT_EQUAL(HIGH, (AND->pin[0]).state);

    destroyModule(AND);
    destroyModuleAndPin(moduleAndPin);
}
void test_notEvent_given_NOT_should_generate_event_for_NOT_module(void)
{
    Module *NOT, *module;
    ModuleAndPin *moduleAndPin;
    int inputType = HEX_INV;

    NOT = createdNotModule(inputType);
    (NOT->pin[4]).state = HIGH;

    moduleAndPin = createdModuleAndPin(NOT, (NOT->pin[4]).pinNumber);

    NOT->event((void *)moduleAndPin, ONE_NANO_SEC);
    module = moduleAndPin->module;

    TEST_ASSERT_EQUAL(LOW, (module->pin[10]).state);

    destroyModule(NOT);
    destroyModuleAndPin(moduleAndPin);
}
void test_andEvent_given_AND_with_QUAD_2_INPUT_should_generate_event_for_AND_module(void)
{
    Module *AND, *module;
    ModuleAndPin *moduleAndPin;
    int inputType = QUAD_2_INPUT;

    AND = createdAndModule(inputType);
    (AND->pin[6]).state = HIGH;
    (AND->pin[7]).state = HIGH;
    moduleAndPin = createdModuleAndPin(AND, (AND->pin[6]).pinNumber);

    AND->event((void *)moduleAndPin, ONE_NANO_SEC);
    module = moduleAndPin->module;

    TEST_ASSERT_EQUAL(HIGH, (module->pin[11]).state);

    destroyModule(AND);
    destroyModuleAndPin(moduleAndPin);
}
void test_setAnd_given_AND_module_and_set_output_of_AND_module_should_throw_ERR_NOT_IN_PIN(void)
{
    CEXCEPTION_T err;
    Module *AND;
    ModuleAndPin *moduleAndPin;
    Node timeNode;
    int inputType = QUAD_2_INPUT;

    AND = createdAndModule(inputType);
    moduleAndPin = createdModuleAndPin(AND, (AND->pin[9]).pinNumber);

    Try{
        AND->set((void *)moduleAndPin, HIGH, ONE_NANO_SEC);
        TEST_FAIL_MESSAGE("Should generate an exception due to ERR_NOT_IN_PIN.");
    } Catch(err) {
        TEST_ASSERT_EQUAL_MESSAGE(ERR_NOT_IN_PIN, err, "Expected ERR_NOT_IN_PIN exception");
    }

    destroyModule(AND);
    destroyModuleAndPin(moduleAndPin);
}
void test_andEvent_given_AND_with_QUAD_2_INPUT_and_connected_to_pipe_should_register_event_for_pipe(void)
{
    Module *AND, *module;
    ModuleAndPin *moduleAndPin;
    Pipe *pipe;
    int inputType = QUAD_2_INPUT;

    AND = createdAndModule(inputType);
    (AND->pin[6]).state = HIGH;
    (AND->pin[7]).state = HIGH;
    pipe = createdPipeModule();
    AND->pin[11].pipe = pipe;
    moduleAndPin = createdModuleAndPin(AND, (AND->pin[6]).pinNumber);

    registerEvent_Expect(NULL, pipe, ONE_NANO_SEC);

    AND->event((void *)moduleAndPin, ONE_NANO_SEC);
    module = moduleAndPin->module;

    TEST_ASSERT_EQUAL(HIGH, (module->pin[11]).state);

    destroyModule(AND);
    destroyModuleAndPin(moduleAndPin);
}
Пример #19
0
NestGeneralFixture::~NestGeneralFixture() {
    // Cleanup the Nest module
    destroyModule(getNestModule());
}