|
| 1 | +/* |
| 2 | + * Teragrep Archive Datasource (pth_06) |
| 3 | + * Copyright (C) 2021-2024 Suomen Kanuuna Oy |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + * |
| 18 | + * |
| 19 | + * Additional permission under GNU Affero General Public License version 3 |
| 20 | + * section 7 |
| 21 | + * |
| 22 | + * If you modify this Program, or any covered work, by linking or combining it |
| 23 | + * with other code, such other code is not for that reason alone subject to any |
| 24 | + * of the requirements of the GNU Affero GPL version 3 as long as this Program |
| 25 | + * is the same Program as licensed from Suomen Kanuuna Oy without any additional |
| 26 | + * modifications. |
| 27 | + * |
| 28 | + * Supplemented terms under GNU Affero General Public License version 3 |
| 29 | + * section 7 |
| 30 | + * |
| 31 | + * Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified |
| 32 | + * versions must be marked as "Modified version of" The Program. |
| 33 | + * |
| 34 | + * Names of the licensors and authors may not be used for publicity purposes. |
| 35 | + * |
| 36 | + * No rights are granted for use of trade names, trademarks, or service marks |
| 37 | + * which are in The Program if any. |
| 38 | + * |
| 39 | + * Licensee must indemnify licensors and authors for any liability that these |
| 40 | + * contractual assumptions impose on licensors and authors. |
| 41 | + * |
| 42 | + * To the extent this program is licensed as part of the Commercial versions of |
| 43 | + * Teragrep, the applicable Commercial License may apply to this file if you as |
| 44 | + * a licensee so wish it. |
| 45 | + */ |
| 46 | +package com.teragrep.pth_06.ast; |
| 47 | + |
| 48 | +import com.teragrep.pth_06.ast.xml.AndExpression; |
| 49 | +import com.teragrep.pth_06.ast.xml.XMLValueExpressionImpl; |
| 50 | +import org.junit.jupiter.api.Assertions; |
| 51 | +import org.junit.jupiter.api.Test; |
| 52 | + |
| 53 | +public final class PrintASTTest { |
| 54 | + |
| 55 | + @Test |
| 56 | + public void printSingleValue() { |
| 57 | + Expression expression = new XMLValueExpressionImpl("value", "operation", Expression.Tag.INDEX); |
| 58 | + String print = new PrintAST(expression).asString(); |
| 59 | + String expected = "VALUE(INDEX val=value op=operation)"; |
| 60 | + Assertions.assertEquals(expected, print); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void printLogical() { |
| 65 | + Expression left = new XMLValueExpressionImpl("earliest", "GE", Expression.Tag.EARLIEST); |
| 66 | + Expression right = new XMLValueExpressionImpl("latest", "LE", Expression.Tag.LATEST); |
| 67 | + Expression expression = new AndExpression(left, right); |
| 68 | + String print = new PrintAST(expression).asString(); |
| 69 | + String expected = "AND\n" + " VALUE(EARLIEST val=earliest op=GE)\n" + " VALUE(LATEST val=latest op=LE)"; |
| 70 | + Assertions.assertEquals(expected, print); |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments