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:
		| @@ -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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dave Borowitz
					Dave Borowitz