當前位置: 首頁>>代碼示例>>Java>>正文


Java Assert.assertEquals方法代碼示例

本文整理匯總了Java中org.junit.Assert.assertEquals方法的典型用法代碼示例。如果您正苦於以下問題:Java Assert.assertEquals方法的具體用法?Java Assert.assertEquals怎麽用?Java Assert.assertEquals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.Assert的用法示例。


在下文中一共展示了Assert.assertEquals方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: utf_8_char

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void utf_8_char() throws IOException {
    String content = "; test EditorConfig files with UTF-8 characters larger than 127\r\n" //
            + "\r\n" //

            + "root = true\r\n" //
            + "\r\n" //
            + "[中文.txt]\r\n" //
            + "key = value\r\n" //
            + "";

    final String testFile = "root/中文.txt";
    StringResourceTree tree = StringResourceTree.builder() //
            .resource("root/.editorconfig", content)//
            .touch(testFile) //
            .build();

    Collection<Property> properties = ResourcePropertiesService.default_()
            .queryProperties(tree.getResource(testFile)).getProperties().values();
    Assert.assertEquals(1, properties.size());
    Assert.assertEquals("key = value", properties.iterator().next().toString());
}
 
開發者ID:ec4j,項目名稱:ec4j,代碼行數:23,代碼來源:EditorConfigGlobTest.java

示例2: test_1

import org.junit.Assert; //導入方法依賴的package包/類
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Long);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:PropertyFilter_long.java

示例3: longCellParsing

import org.junit.Assert; //導入方法依賴的package包/類
@Test
@TestOptions( dataSheet = "TestLong")
public void longCellParsing() throws Exception {

    parser = new ExcelParser(IoUtils.readFile(EXCEL_FILE_PATH), "TestLong");

    Object[][] data = parser.getDataBlock(findMethodByNameOnly("longParseMethod"));

    Assert.assertEquals(data[0][0], 0L);
    Assert.assertEquals(data[1][0], 1234567890123456789L);
    Assert.assertEquals(data[2][0], 9223372036854775807L);
    Assert.assertEquals(data[3][0], 9223372036854775806L);
    Assert.assertEquals(data[4][0], -9223372036854775808L);
    Assert.assertEquals(data[5][0], -9223372036854775807L);
    Assert.assertEquals(data[6][0], 2L);

}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:18,代碼來源:Test_ExcelParser_xls.java

示例4: testQueueParsingShouldTrimSpaces

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testQueueParsingShouldTrimSpaces() throws Exception {
  CapacitySchedulerConfiguration csConf = 
    new CapacitySchedulerConfiguration();
  setupQueueConfigurationWithSpacesShouldBeTrimmed(csConf);
  YarnConfiguration conf = new YarnConfiguration(csConf);

  CapacityScheduler capacityScheduler = new CapacityScheduler();
  capacityScheduler.setConf(conf);
  capacityScheduler.setRMContext(TestUtils.getMockRMContext());
  capacityScheduler.init(conf);
  capacityScheduler.start();
  capacityScheduler.reinitialize(conf, TestUtils.getMockRMContext());
  
  CSQueue a = capacityScheduler.getQueue("a");
  Assert.assertNotNull(a);
  Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA);
  Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA);
  
  CSQueue c = capacityScheduler.getQueue("c");
  Assert.assertNotNull(c);
  Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA);
  Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:TestQueueParsing.java

示例5: testReadBsdiffLong_LongMaxValue

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testReadBsdiffLong_LongMaxValue() throws Exception {
  long expected = 0x7fffffffffffffffL;
  long actual =
      BsPatch.readBsdiffLong(
          new ByteArrayInputStream(
              new byte[] {
                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x7f
              }));
  Assert.assertEquals(expected, actual);
}
 
開發者ID:lizhangqu,項目名稱:CorePatch,代碼行數:13,代碼來源:BsPatchTest.java

示例6: testItem_0068

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0068()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("3.2E-2147483646")).pow(-1);
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:13,代碼來源:TestSuite049.java

示例7: testItem_0041

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0041()
{
  rc_int = (new BigDecimal("0.00")).signum();
  Assert.assertEquals(0, rc_int);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite033.java

示例8: testItem_0526

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0526()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("0.0")).divide(new BigDecimal("1"), 1, -2147483648);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("85.57046979865771%", true, caught);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:13,代碼來源:TestSuite001.java

示例9: recover

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void recover() throws Exception {
    defaultCommitLog.recover();
    Message message = new Message();
    message.getMeta().setTopic("LiQTopic");
    TreeMap<Long, Integer> map = new TreeMap<>();
    for (int i = 0; i < 10; i++) {
        message.setData(("Hello LiQ! " + i).getBytes());
        PutMessageResult result = defaultCommitLog.putMessage(message);
        Assert.assertEquals(PutMessageStatus.PUT_OK,result.getStatus());
        map.put(result.getAppendResult().getWroteOffset(), result.getAppendResult().getWroteBytes());
    }
}
 
開發者ID:taobaorun,項目名稱:LiQ,代碼行數:14,代碼來源:DefaultCommitLogTest.java

示例10: testItem_0853

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0853()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal("SY1?LJWPT2757;14VS=8Q5G3J5W>L2?6F2T6JKTOXM8K>3U4Y67V>86CT;7KB74WP1L9T4:[email protected]?K15T002N5WTL1S;938KE04", new MathContext("precision=0 roundingMode=HALF_EVEN"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.61073825503355%", true, caught);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:13,代碼來源:TestSuite014.java

示例11: testItem_0152

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0152()
{
  rc_BigDecimal = new BigDecimal(4.9E-324);
  Assert.assertEquals("4.940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625E-324", rc_BigDecimal.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite047.java

示例12: testItem_0771

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0771()
{
  rc_BigDecimal = (new BigDecimal("-2E+9")).round(new MathContext("precision=1 roundingMode=HALF_UP"));
  Assert.assertEquals("-2E+9", rc_BigDecimal.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite057.java

示例13: testItem_0748

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0748()
{
  rc_BigDecimal = (new BigDecimal("-51200")).round(new MathContext("precision=2147483647 roundingMode=UP"));
  Assert.assertEquals("-51200", rc_BigDecimal.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite020.java

示例14: testItem_0293

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0293()
{
  rc_BigDecimal = (new BigDecimal("1")).abs();
  Assert.assertEquals("1", rc_BigDecimal.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite006.java

示例15: testItem_0429

import org.junit.Assert; //導入方法依賴的package包/類
public void testItem_0429()
{
  rc_long = (new BigDecimal("9223372036854775807")).longValue();
  Assert.assertEquals(9223372036854775807L, rc_long);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:6,代碼來源:TestSuite021.java


注:本文中的org.junit.Assert.assertEquals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。