@@ -1231,3 +1231,144 @@ fn test_bridge_netns_immutable() {
12311231
12321232 expected. emit ( & mut buf) ;
12331233}
1234+
1235+ #[ test]
1236+ fn test_bridge_flag_display ( ) {
1237+ assert_eq ! ( "master" , BridgeFlag :: Controller . to_string( ) ) ;
1238+ assert_eq ! ( "self" , BridgeFlag :: LowerDev . to_string( ) ) ;
1239+ assert_eq ! ( "255" , BridgeFlag :: Other ( 255 ) . to_string( ) ) ;
1240+ }
1241+
1242+ #[ test]
1243+ fn test_bridge_flag_from_str ( ) {
1244+ use std:: str:: FromStr ;
1245+ assert_eq ! ( BridgeFlag :: Controller , "master" . parse( ) . unwrap( ) ) ;
1246+ assert_eq ! ( BridgeFlag :: LowerDev , "self" . parse( ) . unwrap( ) ) ;
1247+ assert_eq ! ( BridgeFlag :: from( 1 ) , "1" . parse( ) . unwrap( ) ) ;
1248+ assert_eq ! ( BridgeFlag :: from( 2 ) , "2" . parse( ) . unwrap( ) ) ;
1249+ assert_eq ! ( BridgeFlag :: Other ( 99 ) , "99" . parse( ) . unwrap( ) ) ;
1250+ assert ! ( BridgeFlag :: from_str( "bogus" ) . is_err( ) ) ;
1251+ }
1252+
1253+ #[ test]
1254+ fn test_bridge_mode_display ( ) {
1255+ assert_eq ! ( "veb" , BridgeMode :: Veb . to_string( ) ) ;
1256+ assert_eq ! ( "vepa" , BridgeMode :: Vepa . to_string( ) ) ;
1257+ assert_eq ! ( "255" , BridgeMode :: Other ( 255 ) . to_string( ) ) ;
1258+ }
1259+
1260+ #[ test]
1261+ fn test_bridge_mode_from_str ( ) {
1262+ use std:: str:: FromStr ;
1263+ assert_eq ! ( BridgeMode :: Veb , "veb" . parse( ) . unwrap( ) ) ;
1264+ assert_eq ! ( BridgeMode :: Vepa , "vepa" . parse( ) . unwrap( ) ) ;
1265+ assert_eq ! ( BridgeMode :: from( 0 ) , "0" . parse( ) . unwrap( ) ) ;
1266+ assert_eq ! ( BridgeMode :: from( 1 ) , "1" . parse( ) . unwrap( ) ) ;
1267+ assert_eq ! ( BridgeMode :: Other ( 99 ) , "99" . parse( ) . unwrap( ) ) ;
1268+ assert ! ( BridgeMode :: from_str( "bogus" ) . is_err( ) ) ;
1269+ }
1270+
1271+ #[ test]
1272+ fn test_bridge_stp_state_display ( ) {
1273+ assert_eq ! ( "no" , BridgeStpState :: Disabled . to_string( ) ) ;
1274+ assert_eq ! ( "kernel_stp" , BridgeStpState :: KernelStp . to_string( ) ) ;
1275+ assert_eq ! ( "user_stp" , BridgeStpState :: UserStp . to_string( ) ) ;
1276+ assert_eq ! ( "255" , BridgeStpState :: Other ( 255 ) . to_string( ) ) ;
1277+ }
1278+
1279+ #[ test]
1280+ fn test_bridge_stp_state_from_str ( ) {
1281+ use std:: str:: FromStr ;
1282+ assert_eq ! ( BridgeStpState :: Disabled , "no" . parse( ) . unwrap( ) ) ;
1283+ assert_eq ! ( BridgeStpState :: KernelStp , "kernel_stp" . parse( ) . unwrap( ) ) ;
1284+ assert_eq ! ( BridgeStpState :: UserStp , "user_stp" . parse( ) . unwrap( ) ) ;
1285+ assert_eq ! ( BridgeStpState :: Disabled , "0" . parse( ) . unwrap( ) ) ;
1286+ assert_eq ! ( BridgeStpState :: KernelStp , "1" . parse( ) . unwrap( ) ) ;
1287+ assert_eq ! ( BridgeStpState :: UserStp , "2" . parse( ) . unwrap( ) ) ;
1288+ assert_eq ! ( BridgeStpState :: Other ( 99 ) , "99" . parse( ) . unwrap( ) ) ;
1289+ assert ! ( BridgeStpState :: from_str( "bogus" ) . is_err( ) ) ;
1290+ }
1291+
1292+ #[ test]
1293+ fn test_bridge_multicast_router_type_display ( ) {
1294+ assert_eq ! ( "disabled" , BridgeMulticastRouterType :: Disabled . to_string( ) ) ;
1295+ assert_eq ! ( "auto" , BridgeMulticastRouterType :: TempQuery . to_string( ) ) ;
1296+ assert_eq ! (
1297+ "permanent" ,
1298+ BridgeMulticastRouterType :: Permanent . to_string( )
1299+ ) ;
1300+ assert_eq ! ( "temp" , BridgeMulticastRouterType :: Temp . to_string( ) ) ;
1301+ assert_eq ! ( "255" , BridgeMulticastRouterType :: Other ( 255 ) . to_string( ) ) ;
1302+ }
1303+
1304+ #[ test]
1305+ fn test_bridge_multicast_router_type_from_str ( ) {
1306+ use std:: str:: FromStr ;
1307+ assert_eq ! (
1308+ BridgeMulticastRouterType :: Disabled ,
1309+ "disabled" . parse( ) . unwrap( )
1310+ ) ;
1311+ assert_eq ! (
1312+ BridgeMulticastRouterType :: TempQuery ,
1313+ "auto" . parse( ) . unwrap( )
1314+ ) ;
1315+ assert_eq ! (
1316+ BridgeMulticastRouterType :: TempQuery ,
1317+ "temp_query" . parse( ) . unwrap( )
1318+ ) ;
1319+ assert_eq ! (
1320+ BridgeMulticastRouterType :: Permanent ,
1321+ "permanent" . parse( ) . unwrap( )
1322+ ) ;
1323+ assert_eq ! ( BridgeMulticastRouterType :: Temp , "temp" . parse( ) . unwrap( ) ) ;
1324+ assert_eq ! ( BridgeMulticastRouterType :: from( 0 ) , "0" . parse( ) . unwrap( ) ) ;
1325+ assert_eq ! ( BridgeMulticastRouterType :: from( 1 ) , "1" . parse( ) . unwrap( ) ) ;
1326+ assert_eq ! ( BridgeMulticastRouterType :: from( 2 ) , "2" . parse( ) . unwrap( ) ) ;
1327+ assert_eq ! ( BridgeMulticastRouterType :: from( 3 ) , "3" . parse( ) . unwrap( ) ) ;
1328+ assert_eq ! ( BridgeMulticastRouterType :: Other ( 99 ) , "99" . parse( ) . unwrap( ) ) ;
1329+ assert ! ( BridgeMulticastRouterType :: from_str( "bogus" ) . is_err( ) ) ;
1330+ }
1331+
1332+ #[ test]
1333+ fn test_bridge_port_state_display ( ) {
1334+ assert_eq ! ( "disabled" , BridgePortState :: Disabled . to_string( ) ) ;
1335+ assert_eq ! ( "listening" , BridgePortState :: Listening . to_string( ) ) ;
1336+ assert_eq ! ( "learning" , BridgePortState :: Learning . to_string( ) ) ;
1337+ assert_eq ! ( "forwarding" , BridgePortState :: Forwarding . to_string( ) ) ;
1338+ assert_eq ! ( "blocking" , BridgePortState :: Blocking . to_string( ) ) ;
1339+ assert_eq ! ( "255" , BridgePortState :: Other ( 255 ) . to_string( ) ) ;
1340+ }
1341+
1342+ #[ test]
1343+ fn test_bridge_port_state_from_str ( ) {
1344+ use std:: str:: FromStr ;
1345+ assert_eq ! ( BridgePortState :: Disabled , "disabled" . parse( ) . unwrap( ) ) ;
1346+ assert_eq ! ( BridgePortState :: Listening , "listening" . parse( ) . unwrap( ) ) ;
1347+ assert_eq ! ( BridgePortState :: Learning , "learning" . parse( ) . unwrap( ) ) ;
1348+ assert_eq ! ( BridgePortState :: Forwarding , "forwarding" . parse( ) . unwrap( ) ) ;
1349+ assert_eq ! ( BridgePortState :: Blocking , "blocking" . parse( ) . unwrap( ) ) ;
1350+ assert_eq ! ( BridgePortState :: from( 0 ) , "0" . parse( ) . unwrap( ) ) ;
1351+ assert_eq ! ( BridgePortState :: from( 1 ) , "1" . parse( ) . unwrap( ) ) ;
1352+ assert_eq ! ( BridgePortState :: from( 2 ) , "2" . parse( ) . unwrap( ) ) ;
1353+ assert_eq ! ( BridgePortState :: from( 3 ) , "3" . parse( ) . unwrap( ) ) ;
1354+ assert_eq ! ( BridgePortState :: from( 4 ) , "4" . parse( ) . unwrap( ) ) ;
1355+ assert_eq ! ( BridgePortState :: Other ( 99 ) , "99" . parse( ) . unwrap( ) ) ;
1356+ assert ! ( BridgePortState :: from_str( "bogus" ) . is_err( ) ) ;
1357+ }
1358+
1359+ #[ test]
1360+ fn test_vlan_protocol_display ( ) {
1361+ assert_eq ! ( "802.1q" , VlanProtocol :: Ieee8021Q . to_string( ) ) ;
1362+ assert_eq ! ( "802.1ad" , VlanProtocol :: Ieee8021Ad . to_string( ) ) ;
1363+ }
1364+
1365+ #[ test]
1366+ fn test_vlan_protocol_from_str ( ) {
1367+ use std:: str:: FromStr ;
1368+ assert_eq ! ( VlanProtocol :: Ieee8021Q , "802.1q" . parse( ) . unwrap( ) ) ;
1369+ assert_eq ! ( VlanProtocol :: Ieee8021Ad , "802.1ad" . parse( ) . unwrap( ) ) ;
1370+ assert_eq ! ( VlanProtocol :: Ieee8021Q , "802.1Q" . parse( ) . unwrap( ) ) ;
1371+ assert_eq ! ( VlanProtocol :: Ieee8021Ad , "802.1AD" . parse( ) . unwrap( ) ) ;
1372+ assert ! ( VlanProtocol :: from_str( "bogus" ) . is_err( ) ) ;
1373+ assert ! ( VlanProtocol :: from_str( "802.1Qq" ) . is_err( ) ) ;
1374+ }
0 commit comments