Skip to content

Usage of 'step' method #87

Open
Open
@pictavien

Description

@pictavien

Hi,
I've written a small test that plays with Topology.step() method. The aim of the test is to check that N invocations of the method should yield N invocations of the onClock method of a ClockListener. Both assertions at the end of the test fail. Where do I make a mistake ?

import io.jbotsim.core.event.ClockListener;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class TopologyStepTest {
    public static class CycleCounter implements ClockListener {
        public int nbCycles = 0;

        @Override
        public void onClock() {
            nbCycles++;
        }
    }

    @Test
    void test_Step() {
        int N = 10;
        Topology tp = new Topology();
        CycleCounter cc = new CycleCounter();
        tp.addClockListener(cc);

        for (int r = 0; r < N; r++) {
            tp.step();
        }

        assertEquals(N, cc.nbCycles);
        assertFalse(tp.isRunning());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions