When revision statements do not follow guidance from RFC6020/RFC7950
section 7.1.9 and are not order in the order of descending date and
the delta between previous and next version strings is not exactly 1,
we end up picking the wrong version.
This is caused by wrong compareTo() check, which should compare '< 0',
not '== -1'.
Change-Id: Ib7f9a77a9950b6da93ffa30e4c13cc940887ad19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
3c855240dd70f79e7acd9fa98adb8c6a3580f60b)
if (REVISION.equals(subStatementContext.keyword().getText())) {
final String currentRevision = Utils.stringFromStringContext(subStatementContext.argument(),
getReference(source, subStatementContext));
- if (latestRevision == null || latestRevision.compareTo(currentRevision) == -1) {
+ if (latestRevision == null || latestRevision.compareTo(currentRevision) < 0) {
latestRevision = currentRevision;
}
}
assertFalse(info1.equals(info2));
}
+ @Test
+ public void testYangtools827() throws IOException, YangSyntaxErrorException {
+ // Latest revision needs to be picked up irrespective of ordering
+ YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
+ "/bugs/YT827/foo.yang");
+ assertEquals("2014-12-24", info.getFormattedRevision());
+ }
+
@Test
public void testHashcode() throws IOException, YangSyntaxErrorException {
YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
--- /dev/null
+module foo {
+ namespace foo;
+ prefix foo;
+
+ revision "2010-10-10";
+
+ revision "2014-12-24";
+}