Big javadoc update for jgit
[egit/zawir.git] / org.spearce.jgit / tst / org / spearce / jgit / lib / T0001_ObjectId.java
blob90d777909c8ba503ccbc5730be867ff9a51c57b3
1 /*
2 * Copyright (C) 2006 Shawn Pearce <spearce@spearce.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org.spearce.jgit.lib;
19 import junit.framework.TestCase;
21 public class T0001_ObjectId extends TestCase {
22 public void test001_toString() {
23 final String x = "def4c620bc3713bb1bb26b808ec9312548e73946";
24 final ObjectId oid = new ObjectId(x);
25 assertNotNull("has bytes", oid.getBytes());
26 assertEquals(20, oid.getBytes().length);
27 assertEquals(x, oid.toString());
30 public void test002_toString() {
31 final String x = "ff00eedd003713bb1bb26b808ec9312548e73946";
32 final ObjectId oid = new ObjectId(x);
33 assertEquals(x, oid.toString());
36 public void test003_equals() {
37 final String x = "def4c620bc3713bb1bb26b808ec9312548e73946";
38 final ObjectId a = new ObjectId(x);
39 final ObjectId b = new ObjectId(x);
40 assertEquals(a.hashCode(), b.hashCode());
41 assertTrue("a and b are same", a.equals(b));
44 public void test004_isId() {
45 assertTrue("valid id", ObjectId
46 .isId("def4c620bc3713bb1bb26b808ec9312548e73946"));
49 public void test005_notIsId() {
50 assertFalse("bob is not an id", ObjectId.isId("bob"));
53 public void test006_notIsId() {
54 assertFalse("39 digits is not an id", ObjectId
55 .isId("def4c620bc3713bb1bb26b808ec9312548e7394"));
58 public void test007_notIsId() {
59 assertFalse("uppercase is not accepted", ObjectId
60 .isId("Def4c620bc3713bb1bb26b808ec9312548e73946"));
63 public void test008_notIsId() {
64 assertFalse("g is not a valid hex digit", ObjectId
65 .isId("gef4c620bc3713bb1bb26b808ec9312548e73946"));
68 public void test009_toString() {
69 final String x = "ff00eedd003713bb1bb26b808ec9312548e73946";
70 final ObjectId oid = new ObjectId(x);
71 assertEquals(x, ObjectId.toString(oid));
74 public void test010_toString() {
75 final String x = "0000000000000000000000000000000000000000";
76 assertEquals(x, ObjectId.toString(null));