diff options
author | Sorin Basca <sorinbasca@google.com> | 2023-04-27 19:25:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-27 19:25:18 +0000 |
commit | 93f97578b11ca3bbf9a8ed11bd444c63cd9eee47 (patch) | |
tree | 238134d008177eed3ba497ad66ccc1c2feb5e58f /src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java | |
parent | 9c727483a6e538292e2eba7039a74c172bc61c63 (diff) | |
parent | c6b1ae499da7077f964cd5eb4470813f6e07f533 (diff) | |
download | snakeyaml-93f97578b11ca3bbf9a8ed11bd444c63cd9eee47.tar.gz |
Move snakeyaml to v1.32 am: 5352bb310d am: fafcd2ff88 am: c6b1ae499d
Original change: https://android-review.googlesource.com/c/platform/external/snakeyaml/+/2558671
Change-Id: If1f730e9583c505266008b8599a0e4d0e0add162
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java')
-rw-r--r-- | src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java new file mode 100644 index 00000000..5eeec69f --- /dev/null +++ b/src/test/java/org/yaml/snakeyaml/issues/issue449/LeadingZeroStringTest.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2008, SnakeYAML + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.yaml.snakeyaml.issues.issue449; + +import java.util.regex.Pattern; +import junit.framework.TestCase; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.resolver.Resolver; + +public class LeadingZeroStringTest extends TestCase { + + public void testString() { + Yaml loader = new Yaml(); + // this almost looks like an octal, but it contains digits greater than 7, so it's a string + Object result = loader.load("0123456789"); + assertEquals("0123456789", result); + } + + public void testLeadingZeroForIntIsAccepted() { + Pattern regexp = Resolver.INT; + assertTrue("Valid octal must be recognised.", regexp.matcher("07").matches()); + } + + public void testOctalNumberCannotHave8() { + Pattern regexp = Resolver.INT; + assertFalse(regexp.matcher("08").matches()); + assertFalse(regexp.matcher("0123456789").matches()); + } +} |