You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReadLinesTest.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2011-2012, IBM Corporation and others. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.util;
  11. import static org.junit.Assert.assertEquals;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import org.junit.Before;
  15. import org.junit.Test;
  16. public class ReadLinesTest {
  17. List<String> l = new ArrayList<>();
  18. @Before
  19. public void clearList() {
  20. l.clear();
  21. }
  22. @Test
  23. public void testReadLines_singleLine() {
  24. l.add("[0]");
  25. assertEquals(l, IO.readLines("[0]"));
  26. }
  27. @Test
  28. public void testReadLines_LF() {
  29. l.add("[0]");
  30. l.add("[1]");
  31. assertEquals(l, IO.readLines("[0]\n[1]"));
  32. }
  33. @Test
  34. public void testReadLines_CRLF() {
  35. l.add("[0]");
  36. l.add("[1]");
  37. assertEquals(l, IO.readLines("[0]\r\n[1]"));
  38. }
  39. @Test
  40. public void testReadLines_endLF() {
  41. l.add("[0]");
  42. l.add("");
  43. assertEquals(l, IO.readLines("[0]\n"));
  44. }
  45. @Test
  46. public void testReadLines_endCRLF() {
  47. l.add("[0]");
  48. l.add("");
  49. assertEquals(l, IO.readLines("[0]\r\n"));
  50. }
  51. @Test
  52. public void testReadLines_mixed() {
  53. l.add("[0]");
  54. l.add("[1]");
  55. l.add("[2]");
  56. assertEquals(l, IO.readLines("[0]\r\n[1]\n[2]"));
  57. }
  58. }