ChangeNoteUtil: Distinguish between 0 and NaN

RawParseUtils.parseBase10 returns 0 if the input was invalid. The only
way to distinguish between this and a real 0 is by checking whether
the pointer advanced. This was preventing reading changes in NoteDb
with 0 as the line or character offset, which is valid.

Change-Id: I7124abe8a2a2543671bf9da0a51792d44a8ac381
This commit is contained in:
Dave Borowitz
2016-04-20 18:44:44 -04:00
parent 8462ab7e56
commit 2d07ee0143
2 changed files with 58 additions and 9 deletions

View File

@@ -1223,6 +1223,45 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
assertThat(cm.get(1).getPatchSetId()).isEqualTo(ps1);
}
@Test
public void patchLineCommentsFileComment() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
PatchSet.Id psId = c.currentPatchSetId();
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
PatchLineComment comment = newPublishedComment(psId, "file1",
"uuid", null, 0, otherUser, null,
TimeUtil.nowTs(), "message", (short) 1, revId.get());
update.setPatchSetId(psId);
update.putComment(comment);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment));
}
@Test
public void patchLineCommentsZeroColumns() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
PatchSet.Id psId = c.currentPatchSetId();
RevId revId = new RevId("abcd1234abcd1234abcd1234abcd1234abcd1234");
CommentRange range = new CommentRange(1, 0, 2, 0);
PatchLineComment comment = newPublishedComment(psId, "file1",
"uuid", range, range.getEndLine(), otherUser, null,
TimeUtil.nowTs(), "message", (short) 1, revId.get());
update.setPatchSetId(psId);
update.putComment(comment);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment));
}
@Test
public void patchLineCommentNotesFormatSide1() throws Exception {
Change c = newChange();