|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, Roland Bock |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * |
| 8 | + * * Redistributions of source code must retain the above copyright notice, |
| 9 | + * this list of conditions and the following disclaimer. |
| 10 | + * * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer in the documentation |
| 12 | + * and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 15 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 18 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 19 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 20 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 21 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 22 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 23 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 24 | + * POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | + |
| 27 | +#include <sqlpp23/tests/core/all.h> |
| 28 | + |
| 29 | +int main(int, char*[]) { |
| 30 | + const auto val = sqlpp::value(1); |
| 31 | + const auto expr = sqlpp::value(17) + 4; |
| 32 | + |
| 33 | + // Operands are enclosed in parentheses where required. |
| 34 | + SQLPP_COMPARE(val.nulls_last(), "1 NULLS LAST"); |
| 35 | + SQLPP_COMPARE(val.nulls_order(sqlpp::nulls_pos::first), "1 NULLS FIRST"); |
| 36 | + SQLPP_COMPARE(val.nulls_order(sqlpp::nulls_pos::last), "1 NULLS LAST"); |
| 37 | + SQLPP_COMPARE(val.nulls_first(), "1 NULLS FIRST"); |
| 38 | + SQLPP_COMPARE(val.asc(), "1 ASC"); |
| 39 | + SQLPP_COMPARE(val.asc().nulls_first(), "1 ASC NULLS FIRST"); |
| 40 | + SQLPP_COMPARE(val.asc().nulls_last(), "1 ASC NULLS LAST"); |
| 41 | + SQLPP_COMPARE(val.asc().nulls_order(sqlpp::nulls_pos::first), "1 ASC NULLS FIRST"); |
| 42 | + SQLPP_COMPARE(val.asc().nulls_order(sqlpp::nulls_pos::last), "1 ASC NULLS LAST"); |
| 43 | + SQLPP_COMPARE(val.desc(), "1 DESC"); |
| 44 | + SQLPP_COMPARE(val.desc().nulls_first(), "1 DESC NULLS FIRST"); |
| 45 | + SQLPP_COMPARE(val.desc().nulls_last(), "1 DESC NULLS LAST"); |
| 46 | + SQLPP_COMPARE(val.desc().nulls_order(sqlpp::nulls_pos::first), "1 DESC NULLS FIRST"); |
| 47 | + SQLPP_COMPARE(val.desc().nulls_order(sqlpp::nulls_pos::last), "1 DESC NULLS LAST"); |
| 48 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::asc), "1 ASC"); |
| 49 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::asc).nulls_first().nulls_first(), "1 ASC NULLS FIRST"); |
| 50 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::asc).nulls_last(), "1 ASC NULLS LAST"); |
| 51 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::asc).nulls_order(sqlpp::nulls_pos::first), "1 ASC NULLS FIRST"); |
| 52 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::asc).nulls_order(sqlpp::nulls_pos::last), "1 ASC NULLS LAST"); |
| 53 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::desc), "1 DESC"); |
| 54 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::desc).nulls_first(), "1 DESC NULLS FIRST"); |
| 55 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::desc).nulls_last(), "1 DESC NULLS LAST"); |
| 56 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::desc).nulls_order(sqlpp::nulls_pos::first), "1 DESC NULLS FIRST"); |
| 57 | + SQLPP_COMPARE(val.order(sqlpp::sort_type::desc).nulls_order(sqlpp::nulls_pos::last), "1 DESC NULLS LAST"); |
| 58 | + |
| 59 | + SQLPP_COMPARE(expr.nulls_first(), "(17 + 4) NULLS FIRST"); |
| 60 | + SQLPP_COMPARE(expr.nulls_last(), "(17 + 4) NULLS LAST"); |
| 61 | + SQLPP_COMPARE(expr.nulls_order(sqlpp::nulls_pos::first), "(17 + 4) NULLS FIRST"); |
| 62 | + SQLPP_COMPARE(expr.nulls_order(sqlpp::nulls_pos::last), "(17 + 4) NULLS LAST"); |
| 63 | + SQLPP_COMPARE(expr.asc(), "(17 + 4) ASC"); |
| 64 | + SQLPP_COMPARE(expr.asc().nulls_first(), "(17 + 4) ASC NULLS FIRST"); |
| 65 | + SQLPP_COMPARE(expr.asc().nulls_last(), "(17 + 4) ASC NULLS LAST"); |
| 66 | + SQLPP_COMPARE(expr.asc().nulls_order(sqlpp::nulls_pos::first), "(17 + 4) ASC NULLS FIRST"); |
| 67 | + SQLPP_COMPARE(expr.asc().nulls_order(sqlpp::nulls_pos::last), "(17 + 4) ASC NULLS LAST"); |
| 68 | + SQLPP_COMPARE(expr.desc(), "(17 + 4) DESC"); |
| 69 | + SQLPP_COMPARE(expr.desc().nulls_first(), "(17 + 4) DESC NULLS FIRST"); |
| 70 | + SQLPP_COMPARE(expr.desc().nulls_last(), "(17 + 4) DESC NULLS LAST"); |
| 71 | + SQLPP_COMPARE(expr.desc().nulls_order(sqlpp::nulls_pos::first), "(17 + 4) DESC NULLS FIRST"); |
| 72 | + SQLPP_COMPARE(expr.desc().nulls_order(sqlpp::nulls_pos::last), "(17 + 4) DESC NULLS LAST"); |
| 73 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::asc), "(17 + 4) ASC"); |
| 74 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::asc).nulls_first(), "(17 + 4) ASC NULLS FIRST"); |
| 75 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::asc).nulls_last(), "(17 + 4) ASC NULLS LAST"); |
| 76 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::asc).nulls_order(sqlpp::nulls_pos::first), "(17 + 4) ASC NULLS FIRST"); |
| 77 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::asc).nulls_order(sqlpp::nulls_pos::last), "(17 + 4) ASC NULLS LAST"); |
| 78 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::desc), "(17 + 4) DESC"); |
| 79 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::desc).nulls_first(), "(17 + 4) DESC NULLS FIRST"); |
| 80 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::desc).nulls_last(), "(17 + 4) DESC NULLS LAST"); |
| 81 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::desc).nulls_order(sqlpp::nulls_pos::first), "(17 + 4) DESC NULLS FIRST"); |
| 82 | + SQLPP_COMPARE(expr.order(sqlpp::sort_type::desc).nulls_order(sqlpp::nulls_pos::last), "(17 + 4) DESC NULLS LAST"); |
| 83 | + |
| 84 | + return 0; |
| 85 | +} |
0 commit comments