Remove System.out.println from RevWalkFilterTest
[egit/chris.git] / org.spearce.jgit.test / tst / org / spearce / jgit / revwalk / RevObjectTest.java
blob0eaafbf0fe84df88128d9ff20c9de0bed6bf2abe
1 /*
2 * Copyright (C) 2009, Google Inc.
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
8 * conditions are met:
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
21 * written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org.spearce.jgit.revwalk;
40 import org.spearce.jgit.lib.AnyObjectId;
41 import org.spearce.jgit.lib.Constants;
43 public class RevObjectTest extends RevWalkTestCase {
44 public void testId() throws Exception {
45 final RevCommit a = commit();
46 assertSame(a, a.getId());
49 public void testEqualsIsIdentity() throws Exception {
50 final RevCommit a1 = commit();
51 final RevCommit b1 = commit();
53 assertTrue(a1.equals(a1));
54 assertTrue(a1.equals((Object) a1));
55 assertFalse(a1.equals(b1));
57 assertFalse(a1.equals(a1.copy()));
58 assertFalse(a1.equals((Object) a1.copy()));
59 assertFalse(a1.equals(""));
61 final RevWalk rw2 = new RevWalk(db);
62 final RevCommit a2 = rw2.parseCommit(a1);
63 final RevCommit b2 = rw2.parseCommit(b1);
64 assertNotSame(a1, a2);
65 assertNotSame(b1, b2);
67 assertFalse(a1.equals(a2));
68 assertFalse(b1.equals(b2));
70 assertEquals(a1.hashCode(), a2.hashCode());
71 assertEquals(b1.hashCode(), b2.hashCode());
73 assertTrue(AnyObjectId.equals(a1, a2));
74 assertTrue(AnyObjectId.equals(b1, b2));
77 public void testRevObjectTypes() throws Exception {
78 assertEquals(Constants.OBJ_TREE, emptyTree.getType());
79 assertEquals(Constants.OBJ_COMMIT, commit().getType());
80 assertEquals(Constants.OBJ_BLOB, blob("").getType());
81 assertEquals(Constants.OBJ_TAG, tag("emptyTree", emptyTree).getType());
84 public void testHasRevFlag() throws Exception {
85 final RevCommit a = commit();
86 assertFalse(a.has(RevFlag.UNINTERESTING));
87 a.flags |= RevWalk.UNINTERESTING;
88 assertTrue(a.has(RevFlag.UNINTERESTING));
91 public void testHasAnyFlag() throws Exception {
92 final RevCommit a = commit();
93 final RevFlag flag1 = rw.newFlag("flag1");
94 final RevFlag flag2 = rw.newFlag("flag2");
95 final RevFlagSet s = new RevFlagSet();
96 s.add(flag1);
97 s.add(flag2);
99 assertFalse(a.hasAny(s));
100 a.flags |= flag1.mask;
101 assertTrue(a.hasAny(s));
104 public void testHasAllFlag() throws Exception {
105 final RevCommit a = commit();
106 final RevFlag flag1 = rw.newFlag("flag1");
107 final RevFlag flag2 = rw.newFlag("flag2");
108 final RevFlagSet s = new RevFlagSet();
109 s.add(flag1);
110 s.add(flag2);
112 assertFalse(a.hasAll(s));
113 a.flags |= flag1.mask;
114 assertFalse(a.hasAll(s));
115 a.flags |= flag2.mask;
116 assertTrue(a.hasAll(s));
119 public void testAddRevFlag() throws Exception {
120 final RevCommit a = commit();
121 final RevFlag flag1 = rw.newFlag("flag1");
122 final RevFlag flag2 = rw.newFlag("flag2");
123 assertEquals(0, a.flags);
125 a.add(flag1);
126 assertEquals(flag1.mask, a.flags);
128 a.add(flag2);
129 assertEquals(flag1.mask | flag2.mask, a.flags);
132 public void testAddRevFlagSet() throws Exception {
133 final RevCommit a = commit();
134 final RevFlag flag1 = rw.newFlag("flag1");
135 final RevFlag flag2 = rw.newFlag("flag2");
136 final RevFlagSet s = new RevFlagSet();
137 s.add(flag1);
138 s.add(flag2);
140 assertEquals(0, a.flags);
142 a.add(s);
143 assertEquals(flag1.mask | flag2.mask, a.flags);
146 public void testRemoveRevFlag() throws Exception {
147 final RevCommit a = commit();
148 final RevFlag flag1 = rw.newFlag("flag1");
149 final RevFlag flag2 = rw.newFlag("flag2");
150 a.add(flag1);
151 a.add(flag2);
152 assertEquals(flag1.mask | flag2.mask, a.flags);
153 a.remove(flag2);
154 assertEquals(flag1.mask, a.flags);
157 public void testRemoveRevFlagSet() throws Exception {
158 final RevCommit a = commit();
159 final RevFlag flag1 = rw.newFlag("flag1");
160 final RevFlag flag2 = rw.newFlag("flag2");
161 final RevFlag flag3 = rw.newFlag("flag3");
162 final RevFlagSet s = new RevFlagSet();
163 s.add(flag1);
164 s.add(flag2);
165 a.add(flag3);
166 a.add(s);
167 assertEquals(flag1.mask | flag2.mask | flag3.mask, a.flags);
168 a.remove(s);
169 assertEquals(flag3.mask, a.flags);