Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unconditional branch in EncodeTest::aisDecodeEncode #37

Open
Zoybean opened this issue Aug 7, 2018 · 1 comment
Open

Unconditional branch in EncodeTest::aisDecodeEncode #37

Zoybean opened this issue Aug 7, 2018 · 1 comment

Comments

@Zoybean
Copy link

Zoybean commented Aug 7, 2018

The following branch in EncodeTest::aisDecodeEncode is unconditional and prevents the test from verifying any message encodings:

if (!(msg instanceof AisPositionMessage) || !(msg instanceof AisMessage4)
        || !(msg instanceof AisStaticCommon)) {
    vdm = new Vdm();
    continue;
}

The branch is unconditional because the three classes are mutually exclusive subclasses of AisMessage, and the condition is equivalent to testing if msg is an instance of all three:

!(msg instanceof AisPositionMessage && msg instanceof AisMessage4
        && msg instanceof AisStaticCommon)

It appears the intention was:

if (!(msg instanceof AisPositionMessage || msg instanceof AisMessage4
        || msg instanceof AisStaticCommon)) {
    vdm = new Vdm();
    continue;
}

However, the purpose of this is conditional expression is unclear, so I cannot be certain this is correct.

Note:

Due to #35, the change above causes an exception when the test is executed, as one of the later statements calls msg.getEncoded() on an instance of AisMessage24.

@tbsalling
Copy link
Contributor

Hi @Zoybean - thanks; your contribution is welcomed.

Can you please supply a pull request with proposed changes - without reducing current unit test coverage?

Thanks,
/Thomas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants