|
1 | 1 | // expose private and protected members for invasive testing |
2 | | -#include "openPMD/UnitDimension.hpp" |
3 | 2 | #if openPMD_USE_INVASIVE_TESTS |
4 | 3 | #define OPENPMD_private public: |
5 | 4 | #define OPENPMD_protected public: |
@@ -1499,6 +1498,339 @@ TEST_CASE("unavailable_backend", "[core]") |
1499 | 1498 | #endif |
1500 | 1499 | } |
1501 | 1500 |
|
| 1501 | +void breakpoint() |
| 1502 | +{} |
| 1503 | + |
| 1504 | +#if openPMD_HAVE_ADIOS2 |
| 1505 | +TEST_CASE("automatic_variable_encoding", "[adios2]") |
| 1506 | +{ |
| 1507 | + size_t filename_counter = 0; |
| 1508 | + auto filename = [&filename_counter]() { |
| 1509 | + std::stringstream res; |
| 1510 | + res << "../samples/automatic_variable_encoding/test_no_" |
| 1511 | + << filename_counter << ".bp5"; |
| 1512 | + return res.str(); |
| 1513 | + }; |
| 1514 | + auto next_filename = [&filename_counter, &filename]() { |
| 1515 | + ++filename_counter; |
| 1516 | + return filename(); |
| 1517 | + }; |
| 1518 | + auto require_encoding = [&filename](IterationEncoding ie) { |
| 1519 | + Series read(filename(), openPMD::Access::READ_RANDOM_ACCESS); |
| 1520 | + REQUIRE(read.iterationEncoding() == ie); |
| 1521 | + }; |
| 1522 | + |
| 1523 | + // TESTS |
| 1524 | + |
| 1525 | + { |
| 1526 | + Series write(next_filename(), Access::CREATE); |
| 1527 | + write.close(); |
| 1528 | + require_encoding(IterationEncoding::groupBased); |
| 1529 | + } |
| 1530 | + |
| 1531 | + { |
| 1532 | + Series write(next_filename(), Access::CREATE); |
| 1533 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1534 | + write.close(); |
| 1535 | + require_encoding(IterationEncoding::groupBased); |
| 1536 | + } |
| 1537 | + |
| 1538 | + { |
| 1539 | + Series write(next_filename(), Access::CREATE); |
| 1540 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1541 | + write.close(); |
| 1542 | + require_encoding(IterationEncoding::variableBased); |
| 1543 | + } |
| 1544 | + |
| 1545 | + { |
| 1546 | + Series write(next_filename(), Access::CREATE); |
| 1547 | + write.flush(); |
| 1548 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1549 | + write.close(); |
| 1550 | + require_encoding(IterationEncoding::groupBased); |
| 1551 | + } |
| 1552 | + |
| 1553 | + { |
| 1554 | + Series write(next_filename(), Access::CREATE); |
| 1555 | + write.flush(); |
| 1556 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1557 | + write.close(); |
| 1558 | + require_encoding(IterationEncoding::groupBased); |
| 1559 | + } |
| 1560 | + |
| 1561 | + // explicitly set variable encoding |
| 1562 | + |
| 1563 | + { |
| 1564 | + Series write( |
| 1565 | + next_filename(), |
| 1566 | + Access::CREATE, |
| 1567 | + R"(iteration_encoding = "variable_based")"); |
| 1568 | + write.close(); |
| 1569 | + require_encoding(IterationEncoding::variableBased); |
| 1570 | + } |
| 1571 | + |
| 1572 | + { |
| 1573 | + Series write( |
| 1574 | + next_filename(), |
| 1575 | + Access::CREATE, |
| 1576 | + R"(iteration_encoding = "variable_based")"); |
| 1577 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1578 | + write.close(); |
| 1579 | + require_encoding(IterationEncoding::variableBased); |
| 1580 | + } |
| 1581 | + |
| 1582 | + { |
| 1583 | + Series write( |
| 1584 | + next_filename(), |
| 1585 | + Access::CREATE, |
| 1586 | + R"(iteration_encoding = "variable_based")"); |
| 1587 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1588 | + write.close(); |
| 1589 | + require_encoding(IterationEncoding::variableBased); |
| 1590 | + } |
| 1591 | + |
| 1592 | + { |
| 1593 | + Series write( |
| 1594 | + next_filename(), |
| 1595 | + Access::CREATE, |
| 1596 | + R"(iteration_encoding = "variable_based")"); |
| 1597 | + write.flush(); |
| 1598 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1599 | + write.close(); |
| 1600 | + require_encoding(IterationEncoding::variableBased); |
| 1601 | + } |
| 1602 | + |
| 1603 | + { |
| 1604 | + Series write( |
| 1605 | + next_filename(), |
| 1606 | + Access::CREATE, |
| 1607 | + R"(iteration_encoding = "variable_based")"); |
| 1608 | + write.flush(); |
| 1609 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1610 | + write.close(); |
| 1611 | + require_encoding(IterationEncoding::variableBased); |
| 1612 | + } |
| 1613 | + |
| 1614 | + // explicitly set variable encoding |
| 1615 | + |
| 1616 | + { |
| 1617 | + Series write( |
| 1618 | + next_filename(), |
| 1619 | + Access::CREATE, |
| 1620 | + R"(iteration_encoding = "group_based")"); |
| 1621 | + write.close(); |
| 1622 | + require_encoding(IterationEncoding::groupBased); |
| 1623 | + } |
| 1624 | + |
| 1625 | + { |
| 1626 | + Series write( |
| 1627 | + next_filename(), |
| 1628 | + Access::CREATE, |
| 1629 | + R"(iteration_encoding = "group_based")"); |
| 1630 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1631 | + write.close(); |
| 1632 | + require_encoding(IterationEncoding::groupBased); |
| 1633 | + } |
| 1634 | + |
| 1635 | + { |
| 1636 | + Series write( |
| 1637 | + next_filename(), |
| 1638 | + Access::CREATE, |
| 1639 | + R"(iteration_encoding = "group_based")"); |
| 1640 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1641 | + write.close(); |
| 1642 | + require_encoding(IterationEncoding::groupBased); |
| 1643 | + } |
| 1644 | + |
| 1645 | + { |
| 1646 | + Series write( |
| 1647 | + next_filename(), |
| 1648 | + Access::CREATE, |
| 1649 | + R"(iteration_encoding = "group_based")"); |
| 1650 | + write.flush(); |
| 1651 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1652 | + write.close(); |
| 1653 | + require_encoding(IterationEncoding::groupBased); |
| 1654 | + } |
| 1655 | + |
| 1656 | + { |
| 1657 | + Series write( |
| 1658 | + next_filename(), |
| 1659 | + Access::CREATE, |
| 1660 | + R"(iteration_encoding = "group_based")"); |
| 1661 | + write.flush(); |
| 1662 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1663 | + write.close(); |
| 1664 | + require_encoding(IterationEncoding::groupBased); |
| 1665 | + } |
| 1666 | + |
| 1667 | + // explicitly use API call to set variable encoding |
| 1668 | + |
| 1669 | + { |
| 1670 | + Series write(next_filename(), Access::CREATE); |
| 1671 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1672 | + write.close(); |
| 1673 | + require_encoding(IterationEncoding::variableBased); |
| 1674 | + } |
| 1675 | + |
| 1676 | + { |
| 1677 | + Series write(next_filename(), Access::CREATE); |
| 1678 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1679 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1680 | + write.close(); |
| 1681 | + require_encoding(IterationEncoding::variableBased); |
| 1682 | + } |
| 1683 | + |
| 1684 | + { |
| 1685 | + Series write(next_filename(), Access::CREATE); |
| 1686 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1687 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1688 | + write.close(); |
| 1689 | + require_encoding(IterationEncoding::variableBased); |
| 1690 | + } |
| 1691 | + |
| 1692 | + { |
| 1693 | + Series write(next_filename(), Access::CREATE); |
| 1694 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1695 | + write.flush(); |
| 1696 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1697 | + write.close(); |
| 1698 | + require_encoding(IterationEncoding::variableBased); |
| 1699 | + } |
| 1700 | + |
| 1701 | + { |
| 1702 | + Series write(next_filename(), Access::CREATE); |
| 1703 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1704 | + write.flush(); |
| 1705 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1706 | + write.close(); |
| 1707 | + require_encoding(IterationEncoding::variableBased); |
| 1708 | + } |
| 1709 | + |
| 1710 | + // explicitly use API call to set group encoding |
| 1711 | + |
| 1712 | + { |
| 1713 | + Series write(next_filename(), Access::CREATE); |
| 1714 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1715 | + write.close(); |
| 1716 | + require_encoding(IterationEncoding::groupBased); |
| 1717 | + } |
| 1718 | + |
| 1719 | + { |
| 1720 | + Series write(next_filename(), Access::CREATE); |
| 1721 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1722 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1723 | + write.close(); |
| 1724 | + require_encoding(IterationEncoding::groupBased); |
| 1725 | + } |
| 1726 | + |
| 1727 | + { |
| 1728 | + Series write(next_filename(), Access::CREATE); |
| 1729 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1730 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1731 | + write.close(); |
| 1732 | + require_encoding(IterationEncoding::groupBased); |
| 1733 | + } |
| 1734 | + |
| 1735 | + { |
| 1736 | + Series write(next_filename(), Access::CREATE); |
| 1737 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1738 | + write.flush(); |
| 1739 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1740 | + write.close(); |
| 1741 | + require_encoding(IterationEncoding::groupBased); |
| 1742 | + } |
| 1743 | + |
| 1744 | + { |
| 1745 | + Series write(next_filename(), Access::CREATE); |
| 1746 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1747 | + write.flush(); |
| 1748 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1749 | + write.close(); |
| 1750 | + require_encoding(IterationEncoding::groupBased); |
| 1751 | + } |
| 1752 | + |
| 1753 | + // explicitly use API call to set group encoding |
| 1754 | + |
| 1755 | + { |
| 1756 | + Series write(next_filename(), Access::CREATE); |
| 1757 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1758 | + write.close(); |
| 1759 | + require_encoding(IterationEncoding::variableBased); |
| 1760 | + } |
| 1761 | + |
| 1762 | + { |
| 1763 | + Series write(next_filename(), Access::CREATE); |
| 1764 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1765 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1766 | + write.close(); |
| 1767 | + require_encoding(IterationEncoding::variableBased); |
| 1768 | + } |
| 1769 | + |
| 1770 | + { |
| 1771 | + Series write(next_filename(), Access::CREATE); |
| 1772 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1773 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1774 | + write.close(); |
| 1775 | + require_encoding(IterationEncoding::variableBased); |
| 1776 | + } |
| 1777 | + |
| 1778 | + { |
| 1779 | + Series write(next_filename(), Access::CREATE); |
| 1780 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1781 | + write.flush(); |
| 1782 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1783 | + write.close(); |
| 1784 | + require_encoding(IterationEncoding::variableBased); |
| 1785 | + } |
| 1786 | + |
| 1787 | + { |
| 1788 | + Series write(next_filename(), Access::CREATE); |
| 1789 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1790 | + write.flush(); |
| 1791 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1792 | + write.close(); |
| 1793 | + require_encoding(IterationEncoding::variableBased); |
| 1794 | + } |
| 1795 | + |
| 1796 | + // explicitly use API call to set group encoding a bit late |
| 1797 | + |
| 1798 | + { |
| 1799 | + Series write(next_filename(), Access::CREATE); |
| 1800 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1801 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1802 | + write.close(); |
| 1803 | + require_encoding(IterationEncoding::groupBased); |
| 1804 | + } |
| 1805 | + |
| 1806 | + { |
| 1807 | + Series write(next_filename(), Access::CREATE); |
| 1808 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1809 | + write.setIterationEncoding(IterationEncoding::groupBased); |
| 1810 | + write.close(); |
| 1811 | + require_encoding(IterationEncoding::groupBased); |
| 1812 | + } |
| 1813 | + |
| 1814 | + // explicitly use API call to set variable encoding a bit late |
| 1815 | + |
| 1816 | + { |
| 1817 | + Series write(next_filename(), Access::CREATE); |
| 1818 | + write.snapshots(SnapshotWorkflow::RandomAccess); |
| 1819 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1820 | + write.close(); |
| 1821 | + require_encoding(IterationEncoding::variableBased); |
| 1822 | + } |
| 1823 | + |
| 1824 | + { |
| 1825 | + Series write(next_filename(), Access::CREATE); |
| 1826 | + write.snapshots(SnapshotWorkflow::Synchronous); |
| 1827 | + write.setIterationEncoding(IterationEncoding::variableBased); |
| 1828 | + write.close(); |
| 1829 | + require_encoding(IterationEncoding::variableBased); |
| 1830 | + } |
| 1831 | +} |
| 1832 | +#endif |
| 1833 | + |
1502 | 1834 | TEST_CASE("unique_ptr", "[core]") |
1503 | 1835 | { |
1504 | 1836 | auto stdptr = std::make_unique<int>(5); |
|
0 commit comments