def test_plaintext():
    testcase = sealapi.Plaintext()
    assert (testcase.coeff_count() == 0)
    testcase = sealapi.Plaintext(15)
    assert (testcase.coeff_count() == 15)
    testcase = sealapi.Plaintext(100, 15)
    assert (testcase.coeff_count() == 15)
    assert (testcase.capacity() == 100)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.coeff_count() == 4)
    assert (testcase.significant_coeff_count() == 4)
    assert (testcase.capacity() == 4)
    testcase2 = testcase
    assert (testcase2.coeff_count() == 4)
    assert (testcase2.capacity() == 4)
    testcase = sealapi.Plaintext(100, 15)
    testcase.reserve(200)
    assert (testcase.capacity() == 200)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.capacity() == 4)
    testcase.reserve(200)
    assert (testcase.capacity() == 200)
    testcase.shrink_to_fit()
    assert (testcase.capacity() == 4)
    assert (testcase.dyn_array()[3] == 2047)
    assert (testcase.data(3) == 2047)
    assert (testcase.parms_id() == [0, 0, 0, 0])
    assert (testcase.scale == 1.0)
    assert (testcase[3] == 2047)
    assert (testcase.to_string() == '7FFx^3 + 1x^1 + 3')
    testcase.release()
    assert (testcase.coeff_count() == 0)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.coeff_count() == 4)
    assert (testcase.nonzero_coeff_count() == 3)
    testcase.resize(10)
    assert (testcase.coeff_count() == 10)
    testcase.set_zero()
    assert testcase.is_zero()
    assert (testcase.nonzero_coeff_count() == 0)
    testcase = sealapi.Plaintext('7FFx^3 + 2x^1 + 3')
    assert (testcase.is_ntt_form() is False)

    def save_load(path):
        testcase = sealapi.Plaintext('7FFx^3 + 2x^1 + 3')
        testcase.save(path)
        ctx = helper_context_bfv()
        save_test = sealapi.Plaintext()
        save_test.load(ctx, path)
        assert (save_test.coeff_count() == 4)
    tmp_file(save_load)
def test_plaintext():
    testcase = sealapi.Plaintext()
    assert (testcase.coeff_count() == 0)
    testcase = sealapi.Plaintext(15)
    assert (testcase.coeff_count() == 15)
    testcase = sealapi.Plaintext(100, 15)
    assert (testcase.coeff_count() == 15)
    assert (testcase.capacity() == 100)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.coeff_count() == 4)
    assert (testcase.significant_coeff_count() == 4)
    assert (testcase.capacity() == 4)
    testcase2 = testcase
    assert (testcase2.coeff_count() == 4)
    assert (testcase2.capacity() == 4)
    testcase = sealapi.Plaintext(100, 15)
    testcase.reserve(200)
    assert (testcase.capacity() == 200)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.capacity() == 4)
    testcase.reserve(200)
    assert (testcase.capacity() == 200)
    testcase.shrink_to_fit()
    assert (testcase.capacity() == 4)
    assert (testcase.dyn_array()[3] == 2047)
    assert (testcase.data(3) == 2047)
    assert (testcase.parms_id() == [0, 0, 0, 0])
    assert (testcase.scale == 1.0)
    assert (testcase[3] == 2047)
    assert (testcase.to_string() == '7FFx^3 + 1x^1 + 3')
    testcase.release()
    assert (testcase.coeff_count() == 0)
    testcase = sealapi.Plaintext('7FFx^3 + 1x^1 + 3')
    assert (testcase.coeff_count() == 4)
    assert (testcase.nonzero_coeff_count() == 3)
    testcase.resize(10)
    assert (testcase.coeff_count() == 10)
    testcase.set_zero()
    assert testcase.is_zero()
    assert (testcase.nonzero_coeff_count() == 0)
    testcase = sealapi.Plaintext('7FFx^3 + 2x^1 + 3')
    assert (testcase.is_ntt_form() is False)

    def save_load(path):
        testcase = sealapi.Plaintext('7FFx^3 + 2x^1 + 3')
        testcase.save(path)
        ctx = helper_context_bfv()
        save_test = sealapi.Plaintext()
        save_test.load(ctx, path)
        assert (save_test.coeff_count() == 4)
    tmp_file(save_load)