MCPcopy
hub / github.com/grafana/tempo / TestBinOp

Function TestBinOp

pkg/traceql/ast_execute_test.go:1739–1900  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1737}
1738
1739func TestBinOp(t *testing.T) {
1740 testCases := []struct {
1741 op Operator
1742 lhs Static
1743 rhs Static
1744 expected Static
1745 symmetric bool
1746 err error
1747 }{
1748 {
1749 op: OpGreater,
1750 lhs: NewStaticString("foo"),
1751 rhs: NewStaticString(""),
1752 expected: StaticTrue,
1753 },
1754 // Comparisons of strings starting with a number were previously broken.
1755 {
1756 op: OpGreater,
1757 lhs: NewStaticString("123"),
1758 rhs: NewStaticString(""),
1759 expected: StaticTrue,
1760 },
1761 // Test cases for of IN/NOT IN array operations
1762 {
1763 op: OpIn,
1764 lhs: NewStaticInt(2),
1765 rhs: NewStaticIntArray([]int{1, 2, 3}),
1766 expected: StaticTrue,
1767 },
1768 {
1769 op: OpIn,
1770 lhs: NewStaticInt(2),
1771 rhs: NewStaticStringArray([]string{"1", "2", "3"}),
1772 expected: StaticFalse,
1773 },
1774 {
1775 op: OpNotIn,
1776 lhs: NewStaticString("1"),
1777 rhs: NewStaticStringArray([]string{"2", "3", "4"}),
1778 expected: StaticTrue,
1779 },
1780 {
1781 op: OpNotIn,
1782 lhs: NewStaticString("3"),
1783 rhs: NewStaticStringArray([]string{"1", "2", "3"}),
1784 expected: StaticFalse,
1785 },
1786 {
1787 op: OpEqual,
1788 lhs: NewStaticInt(2),
1789 rhs: NewStaticIntArray([]int{1, 2, 3}),
1790 expected: StaticTrue,
1791 symmetric: true,
1792 },
1793 {
1794 op: OpNotEqual,
1795 lhs: NewStaticString("1"),
1796 rhs: NewStaticStringArray([]string{"2", "3", "4"}),

Callers

nothing calls this directly

Calls 10

NewStaticStringFunction · 0.85
NewStaticIntFunction · 0.85
NewStaticIntArrayFunction · 0.85
NewStaticStringArrayFunction · 0.85
NewStaticFloatArrayFunction · 0.85
newBinaryOperationFunction · 0.85
executeMethod · 0.65
ErrorMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected