1ba4fcde58e8bdf79dea0c230dc49957585e9f4d
[mdsal.git] / binding / mdsal-binding-test-model / src / test / java / org / opendaylight / mdsal / binding / test / model / Mdsal661Test.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.test.model;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertThrows;
12
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.mdsal661.norev.Foo;
15
16 public class Mdsal661Test {
17     @Test
18     public void testLengthEnforcerReject() {
19         assertThrows(IllegalArgumentException.class, () -> new Foo(""));
20         assertThrows(IllegalArgumentException.class, () -> new Foo("ab"));
21     }
22
23     @Test
24     public void testLengthEnforcerAccept() {
25         assertNotNull(new Foo("a"));
26         // U+1F31E, encodes to UTF-16 as "\uD83C\uDF1E", i.e. two code units
27         assertNotNull(new Foo("🌞"));
28     }
29 }