Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Jun 11, 2024
1 parent 3cee096 commit c9e0572
Show file tree
Hide file tree
Showing 26 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.morphia.test.query.filters;

import dev.morphia.test.ServerVersion;

import org.testng.annotations.Test;

import static dev.morphia.query.filters.Filters.bitsAnyClear;

public class TestBitsAnyClear extends FilterTest {
@Test
public void testExample1() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnyClear("a", new int[] { 1, 5 })));
}

@Test
public void testExample2() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnyClear("a", 35)));
}

@Test
public void testExample3() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnyClear("a", new byte[] { 48 })));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.morphia.test.query.filters;

import dev.morphia.test.ServerVersion;

import org.testng.annotations.Test;

import static dev.morphia.query.filters.Filters.bitsAnySet;

public class TestBitsAnySet extends FilterTest {
@Test
public void testExample1() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnySet("a", new int[] { 1, 5 })));
}

@Test
public void testExample2() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnySet("a", 35)));
}

@Test
public void testExample3() {
testQuery(ServerVersion.ANY, false, true, (query) -> query.filter(
bitsAnySet("a", new byte[] { 48 })));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnyClear: [ 1, 5 ] } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bit Position Array
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnyClear: 35 } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ "_id" : 1, "a" : 54, "binaryValueofA" : "00110110" }
{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integer Bitmask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnyClear: BinData(0, "MA==") } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BinData Bitmask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnySet: [ 1, 5 ] } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "_id" : 1, "a" : 54, "binaryValueofA" : "00110110" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bit Position Array
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnySet: 35 } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "_id" : 1, "a" : 54, "binaryValueofA" : "00110110" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integer Bitmask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.collection.find( { a: { $bitsAnySet: BinData(0, "MA==") } } )
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ _id: 1, a: 54, binaryValueofA: "00110110" },
{ _id: 2, a: 20, binaryValueofA: "00010100" },
{ _id: 3, a: 20.0, binaryValueofA: "00010100" },
{ _id: 4, a: BinData(0, "Zg=="), binaryValueofA: "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ "_id" : 1, "a" : 54, "binaryValueofA" : "00110110" }
{ "_id" : 2, "a" : 20, "binaryValueofA" : "00010100" }
{ "_id" : 3, "a" : 20.0, "binaryValueofA" : "00010100" }
{ "_id" : 4, "a" : BinData(0,"Zg=="), "binaryValueofA" : "01100110" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BinData Bitmask

0 comments on commit c9e0572

Please sign in to comment.